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

ssl.SSLCertVerificationError #60

Closed
franciscojnneto opened this issue Nov 16, 2022 · 1 comment · Fixed by #74
Closed

ssl.SSLCertVerificationError #60

franciscojnneto opened this issue Nov 16, 2022 · 1 comment · Fixed by #74

Comments

@franciscojnneto
Copy link

This is not a bug, but i need help to bypass this error.

where i can change hostname(IP) to match machinename/hostname


/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/urllib3/connection.py:455: SubjectAltNameWarning: Certificate for 192.168.1.82 has no subjectAltName, falling back to check for a commonName for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See urllib3/urllib3#497 for details.)
warnings.warn(
Traceback (most recent call last):
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/urllib3/connection.py", line 464, in connect
_match_hostname(cert, self.assert_hostname or server_hostname)
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/urllib3/connection.py", line 512, in _match_hostname
match_hostname(cert, asserted_hostname)
File "/usr/lib/python3.9/ssl.py", line 420, in match_hostname
raise CertificateError("hostname %r "
ssl.SSLCertVerificationError: ("hostname '192.168.1.82' doesn't match 'backupserver02'",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.1.82', port=443): Max retries exceeded with url: /api/ (Caused by SSLError(SSLCertVerificationError("hostname '192.168.1.82' doesn't match 'backupserver02'")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/francisco/Netbox-Device-Type-Library-Import/./nb-dt-import.py", line 856, in
main()
File "/home/francisco/Netbox-Device-Type-Library-Import/./nb-dt-import.py", line 779, in main
determine_features(nb)
File "/home/francisco/Netbox-Device-Type-Library-Import/./nb-dt-import.py", line 42, in determine_features
nb_ver = [int(x) for x in nb.version.split('.')]
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/pynetbox/api.py", line 212, in version
version = Request(
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/pynetbox/core/query.py", line 181, in get_version
req = requests.get(
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/home/francisco/Netbox-Device-Type-Library-Import/venv/lib/python3.9/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='192.168.1.82', port=443): Max retries exceeded with url: /api/ (Caused by SSLError(SSLCertVerificationError("hostname '192.168.1.82' doesn't match 'backupserver02'")))

@danner26
Copy link
Member

danner26 commented Mar 3, 2023

Hey @franciscojnneto. I have implemented a fix that will solve this SSL issue. Now, when you utilize the IGNORE_SSL_ERRORS=True definition, the library will properly ignore the SSL errors and initialize the API connection. This causes the library to A) suppress the SSL verification warning messages, and B) allow the API transaction to be successful. If you ever require more verbosity, you can also use the --verbose flag which will show you the raised exception. Note: the --verbose flag is new and will be further implemented throughout the library when possible

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 a pull request may close this issue.

2 participants