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

inject_into_ssl() not working in virtual environment (Windows 10) #155

Open
mydoghasfleas opened this issue Sep 5, 2024 · 3 comments
Open

Comments

@mydoghasfleas
Copy link

I am using truststore.inject_into_ssl() for a little app/script.

When I run it in a virtual environment (where I installed truststore separately) it gives me an error (see below).

When I run the same thing directly with my Python interpreter installed in Windows (10), it works.

Is there something I am missing in my virtual environment setup?

  File "C:\Users\user1\Development\python\myapp\Lib\site-packages\requests\sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user1\Development\python\myapp\Lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user1\Development\python\myapp\Lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user1\Development\python\myapp\Lib\site-packages\requests\adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "C:\Users\user1\Development\python\myapp\Lib\site-packages\urllib3\connectionpool.py", line 789, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user1\Development\python\myapp\Lib\site-packages\urllib3\connectionpool.py", line 466, in _make_request
    self._validate_conn(conn)
  File "C:\Users\user1\Development\python\myapp\Lib\site-packages\urllib3\connectionpool.py", line 1095, in _validate_conn
    conn.connect()
  File "C:\Users\user1\Development\python\myapp\Lib\site-packages\urllib3\connection.py", line 652, in connect
    sock_and_verified = _ssl_wrap_socket_and_match_hostname(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user1\Development\python\myapp\Lib\site-packages\urllib3\connection.py", line 767, in _ssl_wrap_socket_and_match_hostname
    context.verify_mode = resolve_cert_reqs(cert_reqs)
    ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user1\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 742, in verify_mode
    super(SSLContext, SSLContext).verify_mode.__set__(self, value)
  File "C:\Users\user1\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 742, in verify_mode
    super(SSLContext, SSLContext).verify_mode.__set__(self, value)
  File "C:\Users\user1\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 742, in verify_mode
    super(SSLContext, SSLContext).verify_mode.__set__(self, value)
  [Previous line repeated 491 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

The following is what pip list reports in my virtual environment:

Package            Version
------------------ ---------
certifi            2024.8.30
charset-normalizer 3.3.2
idna               3.8
numpy              2.1.1
pillow             10.4.0
pip                22.3.1
requests           2.32.3
setuptools         65.5.0
six                1.16.0
truststore         0.9.2
urllib3            2.2.2
wxPython           4.2.1
@mydoghasfleas
Copy link
Author

By the way, I should add: I am working behind a corporate firewall, if that makes any difference.

@davisagli
Copy link
Collaborator

This might be the same issue that is discussed in #143

@mydoghasfleas
Copy link
Author

@davisagli Thank you, that issue pointed me in the right direction.

Comparing the versions of the requests library in my global and pyenv installations, I saw that globally I had 2.28.2, while in the virtual environment I had 2.32.3.

Downgrading to 2.28.2 in the virtual environment did indeed solve the problem. (And I also had this on Linux/WSL, by the way).

Can one conclude from that, that the problem is with requests, or could it be a conjunctive problem between the libraries?

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

2 participants