SSL: WRONG_VERSION_NUMBER during python requests.get
Asked Answered
D

0

7

I am trying to access a pypi url like this:

PYPI_URL = https://pypi.org/pypi/Django/json

try:
    response = requests.get(PYPI_URL)

except requests.exceptions.RequestException as err:
    print("Unable to access Pypi. ", err)

But when I am trying to generate vcr cassettes for a pytest, I get this error.

E       AssertionError: assert 'Unable to access Pypi' not in "Unable to acce...l.c:1108)')))\n"
E         'Unable to access Pypi' is contained here:
E           Unable to access Pypi. Error Connecting:  HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi/Django/json (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1108)')))
E         ? +++++++++++++++++++++

What am I doing wrong? Why does it complain only when I try to generate cassette? The test passes if I just run pytest without generating VCR cassette.

Dodgem answered 27/7, 2020 at 20:1 Comment(3)
I found this bit on a problem similar to this, it appears to be that the problem is SSL doesn't return a very informative error when the wrong port is used. If you can find out what port you should access, and compare that to what you are accessing, that may be a step in the right direction. bugs.python.org/issue35422Mike
I am using port 80. How to find which port I should be using?Dodgem
Looks like your Python installation is compiled against an old version of OpenSSL. What are: 1. your Python version (python -V), 2. your OpenSSL version (openssl version) and 3. the version of OpenSSL Python was linked against (python -c "import ssl; print(ssl.OPENSSL_VERSION)")?Seaden

© 2022 - 2024 — McMap. All rights reserved.