1

Context

I am working behind a corporate proxy with a self-signed certificate. I have documented this extensively.

The issue now is that TLS/SSL module is not loading correctly to even verify the certificates.

  • Windows 10
  • Anaconda 2018.12 (Python 3.7.1)
  • git version 2.19.0.windows.1

Question

python -c "import ssl"

I can get it to work in Anaconda Prompt, but not in Git Bash. Why is there a difference?

Steps

Using Git Bash

I started with the basic install of the latest (at time of writing) Anaconda distribution 2018.12 and tried to install redis.

$ pip install redis
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting redis
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/redis/
  ...
  Could not fetch URL https://pypi.org/simple/redis/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/redis/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Could not find a version that satisfies the requirement redis (from versions: )
No matching distribution found for redis

So that is weird. SSLError("Can't connect to HTTPS URL because the SSL module is not available."). So I tried just importing ssl.

$ python -c "import ssl"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.

Anaconda Prompt

(base) C:\Users\username> python -c "import ssl"

(base) C:\Users\username> 

No errors. Just a blank line.

(base) C:\Users\username> conda deactivate
C:\Users\username>
C:\Users\username> python -c "import ssl"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.

After deactivating the base conda environment I can replicate the error in an Anaconda Prompt.

Summary

So obviously the _ssl.pyd file in C:\Users\username\AppData\Local\Continuum\anaconda3\DLLs does work but there is something I'm missing or do not know how to debug further to figure out why it does not work in Git Bash.

I do not understand how to debug how python loads DLLs and how Anaconda environments influences this.

2 Answers 2

0

Since git bash seemed to be what was different I tried updating it from 2.19.0 to 2.20.1 and it now works in Git Bash.

Which is weird since both versions were configured to use the Windows Secure Channel backend for TLS/SSL.

[http]
    sslBackend=schannel

Update: Git V2.20.0 release notes

https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.20.0.txt

Updates since v2.19

UI, Workflows & Features

  • On platforms with recent cURL library, http.sslBackend configuration variable can be used to choose a different SSL backend at runtime. The Windows port uses this mechanism to switch between OpenSSL and Secure Channel while talking over the HTTPS protocol.

Performance, Internal Implementation, Development Support etc.

  • The way DLLs are loaded on the Windows port has been improved.

These seem to be the only changes in Git Bash that could have caused the issue. I thought it was using Windows Secure Channel but perhaps it was using Git Bash OpenSSL previously and updating points it at schannel

Alternatively there was an issue with how the msys terminal emulator loaded in DLLs.

0

Maybe this could help. Hint from Git 2.22.0 Setup

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.