-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
setuptools fails in corporate MITM proxy with intermediate SSL cacerts #1630
Comments
This is as true as possible and is breaking the package installation for everyone using a proxy. PIP works well with the same proxy but in some cases it needs to use setuptools (easy_install) to install some setup_requires packages and at this point it will chocke because setuptools is totally clueless when it comes to the custom CA used by the proxy. For example in addition to the standard
This tells to the SSL libraries to use the bundle that contains our own CA certificate. Curl works, python requests (uses urllib3) works, and python in general works. But not setuptools. I was not able to find any workaround for this, other than disabling the http_proxy which is a serious issue. This is related to #1543 but I think that instead of adding new configuration items which would require changing the proxy enablement deployment, it would be better to reuse one of the already known environment variables, likely SSL_CERT_FILE being the best candidate. |
@ssbarnea Disabling http_proxy is not a possibility for me it's a enterprise wide setting and there's no http(s)_proxy variable set on our local machines. It might help if setuptools can help with some sort of configuration parameter. SSL_CERT_FILE doesn't seem to be working in my case. I was able to get this running for conda(.condarc file) and pip(.piprc file) based package installations but not setuptools |
FYI in ssl_support.py def opener_for(ca_bundle=None):
"""Get a urlopen() replacement that uses ca_bundle for verification"""
return urllib.request.build_opener(
VerifyingHTTPSHandler(ca_bundle or find_ca_bundle())
).open setuptools seems to be using urllib |
Here's what worked for me (python3): |
To fix this properly imho s.th. like such a patch would be necessary:
IIUC understand easy_install is deprecated and will be replaced by pip but it looks like setup_requires still installs via easy_install, so this might still be helpful. I could prepare a pull request but I'd need a hint at how to write a proper test for this. Do the unittests actually connect to pypi or do stuff locally, only? |
On a closer look it would probably be better to concentrate this in the ssl_support module and leave easy_install be altogether:
This makes testing rather trivial as you can simply test if a given env setting will get respected by |
Temporal solution of #1543, #1821 is overwriting cert_paths in from setuptools import setup
import setuptools.ssl_support
setuptools.ssl_support.cert_paths = ['/path/to/cafile']
setup() setuptools/setuptools/ssl_support.py Line 21 in 17ad2b7
|
@eholic thanks worked like a charm! In my case to make it more "portable" I used
Note to others: I had to use full path |
@bclodius Thank you. It would be better according to @hjoukl's PR#1821. from setuptools import setup
import os
import setuptools.ssl_support
ca_bundle = (os.environ.get('SSL_CERT_FILE') or
os.environ.get('REQUESTS_CA_BUNDLE') or
os.environ.get('CURL_CA_BUNDLE'))
if ca_bundle:
setuptools.ssl_support.cert_paths = [ca_bundle]
setup() |
I believe the need for this has been obviated by #1830. Please comment if not. |
I was looking at the following piece of code in package_index.py:
I have added/appened the corporate CA certificates to /etc/ssl/cert.pem but setuptools never actually picks it up or uses it. Did anyone ever solve this?
FYI I am on a MacOS and using Anaconda with Python 3.6
Error that I get:
The text was updated successfully, but these errors were encountered: