如何让easy_install忽略certifcate

Jac*_*kie 9 python easy-install

我们的网络安装不是最好的,所以我需要告诉通过ssl进行通信的应用程序忽略证书.不得不用NPM等做同样的事情所以现在当我跑...

$ easy_install pip
...
Download error on https://pypi.python.org/simple/pip/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) -- Some packages may not be found!
Run Code Online (Sandbox Code Playgroud)

那么我该如何关闭此验证呢?

PS我知道这是一个安全载体,但幽默我.

bor*_*car 10

我相信你的easy_install最终会转到setuptools,它有自己的SSL帮助器.在我的Linux它是在/usr/lib/python2.7/site-packages/setuptools/ssl_support.py.基本上有两种方式:

  1. 我建议获取证书并手动添加它,您将在ssl_support.py中找到位置.这些线引起了我的注意:

    cert_paths = """
    /etc/pki/tls/certs/ca-bundle.crt
    /etc/ssl/certs/ca-certificates.crt
    /usr/share/ssl/certs/ca-bundle.crt
    /usr/local/share/certs/ca-root.crt
    /etc/ssl/cert.pem
    /System/Library/OpenSSL/certs/cert.pem
    """.strip().split()
    
    Run Code Online (Sandbox Code Playgroud)

    只需将您的证书附加到其中任何一个.在这里看到了如何使用OpenSSL的的s_client.First获得certifiate:使用OpenSSL来从服务器获取证书

  2. 进一步了解一下,您可以在setuptools帮助程序中完全禁用SSL验证.ssl_support.py中的以下几行引起了我的注意:

    try:
      import ssl
    except ImportError:
      ssl = None
    
    Run Code Online (Sandbox Code Playgroud)

    我刚刚添加了ssl = None,所以:

    try:
      import ssl
    except ImportError:
      ssl = None
    
    ssl = None
    
    Run Code Online (Sandbox Code Playgroud)

  • 谢谢,问题本身就是它是签名者的证书.我的雇主基本上是在他们网络中的所有https请求中导致所有SSL验证都有问题.重点是我不确定我可以添加证书并让它工作,但我不是安全专家. (2认同)