Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NXOS: Set session wide SSL verification to False for HTTPS URLs #137

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

SohanTirpude
Copy link

@SohanTirpude SohanTirpude commented Nov 26, 2024

Description

Seeing SSLCertVerificationError while making any request to the server. But, after setting session wide SSL certificate verification to False, we are able to make any requests to the server.
Reference: https://www.geeksforgeeks.org/how-to-disable-security-certificate-checks-for-requests-in-python/

Fail Log

4044:  Sending POST command to 'uut':
4045:  DN: https://x.x.x.x:443/api/mo/sys.json
4046:  Payload:{ ... }
4091:  Request POST to https://x.x.x.x:443/api/mo/sys.json failed. Waiting 10 seconds before retrying
4092:  Traceback (most recent call last):
4093:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 716, in urlopen
4094:      httplib_response = self._make_request(
4095:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 404, in _make_request
4096:      self._validate_conn(conn)
4097:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1061, in _validate_conn
4098:      conn.connect()
4099:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connection.py", line 419, in connect
4100:      self.sock = ssl_wrap_socket(
4101:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 462, in ssl_wrap_socket
4102:      ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
4103:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 504, in _ssl_wrap_socket_impl
4104:      return ssl_context.wrap_socket(sock)
4105:    File "/auto/pysw/cel8x/python64/3.10.10/lib/python3.10/ssl.py", line 513, in wrap_socket
4106:      return self.sslsocket_class._create(
4107:    File "/auto/pysw/cel8x/python64/3.10.10/lib/python3.10/ssl.py", line 1071, in _create
4108:      self.do_handshake()
4109:    File "/auto/pysw/cel8x/python64/3.10.10/lib/python3.10/ssl.py", line 1342, in do_handshake
4110:      self._sslobj.do_handshake()
4111:  ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)
4112: 
4113:  During handling of the above exception, another exception occurred:
4114: 
4115:  Traceback (most recent call last):
4116:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/adapters.py", line 667, in send
4117:      resp = conn.urlopen(
4118:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 802, in urlopen
4119:      retries = retries.increment(
4120:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/util/retry.py", line 594, in increment
4121:      raise MaxRetryError(_pool, url, error or ResponseError(cause))
4122:  urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: /api/mo/sys.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)')))
4123: 
4124:  During handling of the above exception, another exception occurred:
4125: 
4126:  Traceback (most recent call last):
4127:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/rest/connector/libs/nxos/implementation.py", line 292, in _request
4128:      response = self.session.request(
4129:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
4130:      resp = self.send(prep, **send_kwargs)
4131:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
4132:      r = adapter.send(request, **kwargs)
4133:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/adapters.py", line 698, in send
4134:      raise SSLError(e, request=request)
4135:  requests.exceptions.SSLError: HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: /api/mo/sys.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)')))
4136:  Request POST to https://x.x.x.x:443/api/mo/sys.json failed. Waiting 10 seconds before retrying
4137:  Traceback (most recent call last):
4138:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 716, in urlopen
4139:      httplib_response = self._make_request(
4140:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 404, in _make_request
4141:      self._validate_conn(conn)
4142:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1061, in _validate_conn
4143:      conn.connect()
4144:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connection.py", line 419, in connect
4145:      self.sock = ssl_wrap_socket(
4146:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 462, in ssl_wrap_socket
4147:      ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
4148:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 504, in _ssl_wrap_socket_impl
4149:      return ssl_context.wrap_socket(sock)
4150:    File "/auto/pysw/cel8x/python64/3.10.10/lib/python3.10/ssl.py", line 513, in wrap_socket
4151:      return self.sslsocket_class._create(
4152:    File "/auto/pysw/cel8x/python64/3.10.10/lib/python3.10/ssl.py", line 1071, in _create
4153:      self.do_handshake()
4154:    File "/auto/pysw/cel8x/python64/3.10.10/lib/python3.10/ssl.py", line 1342, in do_handshake
4155:      self._sslobj.do_handshake()
4156:  ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)
4157: 
4158:  During handling of the above exception, another exception occurred:
4159: 
4160:  Traceback (most recent call last):
4161:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/adapters.py", line 667, in send
4162:      resp = conn.urlopen(
4163:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 802, in urlopen
4164:      retries = retries.increment(
4165:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/util/retry.py", line 594, in increment
4166:      raise MaxRetryError(_pool, url, error or ResponseError(cause))
4167:  urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: /api/mo/sys.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)')))
4168: 
4169:  During handling of the above exception, another exception occurred:
4170: 
4171:  Traceback (most recent call last):
4172:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/rest/connector/libs/nxos/implementation.py", line 292, in _request
4173:      response = self.session.request(
4174:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
4175:      resp = self.send(prep, **send_kwargs)
4176:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
4177:      r = adapter.send(request, **kwargs)
4178:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/adapters.py", line 698, in send
4179:      raise SSLError(e, request=request)
4180:  requests.exceptions.SSLError: HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: /api/mo/sys.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)')))
4181:  Request POST to https://x.x.x.x:443/api/mo/sys.json failed. Waiting 10 seconds before retrying
4182:  Traceback (most recent call last):
4183:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 716, in urlopen
4184:      httplib_response = self._make_request(
4185:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 404, in _make_request
4186:      self._validate_conn(conn)
4187:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1061, in _validate_conn
4188:      conn.connect()
4189:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connection.py", line 419, in connect
4190:      self.sock = ssl_wrap_socket(
4191:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 462, in ssl_wrap_socket
4192:      ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
4193:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 504, in _ssl_wrap_socket_impl
4194:      return ssl_context.wrap_socket(sock)
4195:    File "/auto/pysw/cel8x/python64/3.10.10/lib/python3.10/ssl.py", line 513, in wrap_socket
4196:      return self.sslsocket_class._create(
4197:    File "/auto/pysw/cel8x/python64/3.10.10/lib/python3.10/ssl.py", line 1071, in _create
4198:      self.do_handshake()
4199:    File "/auto/pysw/cel8x/python64/3.10.10/lib/python3.10/ssl.py", line 1342, in do_handshake
4200:      self._sslobj.do_handshake()
4201:  ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)
4202: 
4203:  During handling of the above exception, another exception occurred:
4204: 
4205:  Traceback (most recent call last):
4206:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/adapters.py", line 667, in send
4207:      resp = conn.urlopen(
4208:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/connectionpool.py", line 802, in urlopen
4209:      retries = retries.increment(
4210:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/urllib3/util/retry.py", line 594, in increment
4211:      raise MaxRetryError(_pool, url, error or ResponseError(cause))
4212:  urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: /api/mo/sys.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)')))
4213: 
4214:  During handling of the above exception, another exception occurred:
4215: 
4216:  Traceback (most recent call last):
4217:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/rest/connector/libs/nxos/implementation.py", line 292, in _request
4218:      response = self.session.request(
4219:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
4220:      resp = self.send(prep, **send_kwargs)
4221:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
4222:      r = adapter.send(request, **kwargs)
4223:    File "/auto/nextssr-bgl/pyatsProd_bgl12/lib/python3.10/site-packages/requests/adapters.py", line 698, in send
4224:      raise SSLError(e, request=request)
4225:  requests.exceptions.SSLError: HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: /api/mo/sys.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)')))

Pass Log

161:  Sending POST command to 'uut':
162:  DN: https://x.x.x.x:443/api/mo/sys.json
163:  Payload:{ ... }
208:  Response from 'uut':
209:  Result Code: 200
210:  Response: {"imdata":[]}
211:  {'imdata': []}

@SohanTirpude SohanTirpude requested a review from a team as a code owner November 26, 2024 11:55
@Taarini Taarini requested review from Taarini and removed request for sanjaydilli November 26, 2024 14:45
Copy link
Contributor

@Taarini Taarini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add snippet of error log and pass log

@SohanTirpude
Copy link
Author

Hello @lsheikal, kindly review the PR.

2 similar comments
@SohanTirpude
Copy link
Author

Hello @lsheikal, kindly review the PR.

@SohanTirpude
Copy link
Author

Hello @lsheikal, kindly review the PR.

@Taarini Taarini requested a review from ThomasJRyan December 13, 2024 15:45
@ThomasJRyan ThomasJRyan merged commit 4475c68 into main Dec 16, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants