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: WRONG_VERSION_NUMBER #122

Open
anubisg1 opened this issue Jan 8, 2024 · 0 comments
Open

SSL: WRONG_VERSION_NUMBER #122

anubisg1 opened this issue Jan 8, 2024 · 0 comments

Comments

@anubisg1
Copy link

anubisg1 commented Jan 8, 2024

This is a dependency problem that should be documented at least.
Another solution is to hardcode in the requirements a version of urllib3 without the bug.

the issue is the same as described here:

https://stackoverflow.com/questions/65516325/ssl-wrong-version-number-on-python-request

there are 2 solutions/workarounds

  1. in the env environment, when writing the netbox URL, use "http://" instead of "https://"
  2. install a bug free version of urllib3

when running the script i got the following

(venv) anubisg1@CZPRG-6VJY9Y3:~/Device-Type-Library-Import$ ./nb-dt-import.py
Package devicetype-library is already installed, updating /home/anubisg1/Device-Type-Library-Import/repo
Traceback (most recent call last):
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    self._validate_conn(conn)
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1096, in _validate_conn
    conn.connect()
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/connection.py", line 642, in connect
    sock_and_verified = _ssl_wrap_socket_and_match_hostname(
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/connection.py", line 782, in _ssl_wrap_socket_and_match_hostname
    ssl_sock = ssl_wrap_socket(
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 470, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 514, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.10/ssl.py", line 1100, in _create
    self.do_handshake()
  File "/usr/lib/python3.10/ssl.py", line 1371, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1007)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 491, in _make_request
    raise new_e
urllib3.exceptions.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1007)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 844, in urlopen
    retries = retries.increment(
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.0.177', port=8000): Max retries exceeded with url: /api/ (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1007)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anubisg1/Device-Type-Library-Import/./nb-dt-import.py", line 54, in <module>
    main()
  File "/home/anubisg1/Device-Type-Library-Import/./nb-dt-import.py", line 17, in main
    netbox = NetBox(settings)
  File "/home/anubisg1/Device-Type-Library-Import/netbox_api.py", line 28, in __init__
    self.verify_compatibility()
  File "/home/anubisg1/Device-Type-Library-Import/netbox_api.py", line 50, in verify_compatibility
    version_split = [int(x) for x in self.netbox.version.split('.')]
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/pynetbox/core/api.py", line 109, in version
    ).get_version()
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/pynetbox/core/query.py", line 180, in get_version
    req = self.http_session.get(
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/home/anubisg1/Device-Type-Library-Import/venv/lib/python3.10/site-packages/requests/adapters.py", line 517, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='192.168.0.177', port=8000): Max retries exceeded with url: /api/ (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1007)')))
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

No branches or pull requests

1 participant