python - pip:证书失败,但 curl 有效

标签 python curl ssl pip

我们在客户端安装了我们的根证书,并且 https 连接适用于 curl

但是如果我们尝试使用 pip,它会失败:

Could not fetch URL https://installserver:40443/pypi/simple/pep8/:
There was a problem confirming the ssl certificate: 
<urlopen error [Errno 1] _ssl.c:499: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed>

证书在客户端。见:

(foo_fm_qti)foo_fm_qti@vis-work:~$ curl -v https://installserver:40443/pypi/simple/pep8/
* About to connect() to installserver port 40443 (#0)
*   Trying 127.0.0.1... connected
* Connected to installserver (127.0.0.1) port 40443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs/
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS alert, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
*    subject: C=DE; ST=Sachsen; L=Chemnitz; O=FOO-COM GmbH; OU=DV; CN=gray.foo-com.lan; emailAddress=info@foo-com.de
*    start date: 2013-09-09 10:47:50 GMT
*    expire date: 2019-05-24 10:47:50 GMT
*    subjectAltName: installserver matched
*    issuer: C=DE; ST=Sachsen; L=Chemnitz; O=FOO-COM GmbH; CN=FOO-COM Root CA; emailAddress=info@foo-com.de
*    SSL certificate verify ok.
> GET /pypi/simple/pep8/ HTTP/1.1

版本:pip 1.4.1

最佳答案

不幸的是,pip 不使用系统证书,但 curl 可以。

我找到了一个解决方案:

pip --cert /etc/ssl/certs/FOO_Root_CA.pem install pep8

这不是很好(curl 和其他库在不添加参数的情况下找到证书)但有效。

如果你不想使用命令行参数,你可以在 ~/.pip/pip.conf 中设置证书:

[global]
cert = /etc/ssl/certs/Foo_Root_CA.pem

关于python - pip:证书失败,但 curl 有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18273015/

相关文章:

node.js - 为什么我们应该避免在 Ubuntu 上使用 apt-get 安装 Node.js?

php - 如何使用 cURL progress_callback 计算下载速度 (PHP)

.net - 对于使用服务堆栈创建的服务,如何使用 SSL 保护我的服务?

openssl - 尝试使用此代码通过 TLS 运行 TLS 时,为什么会出现握手失败?

java - 为即将到来的 SSL 调用配置 WebSphere 服务器的正确方法

python - 如何在 numpy 中仅将字符串数组的整数转换为 float 数组?

php - PayPal Express Checkout 始终显示用户 "This transaction has expired."页面,但没有 API 错误

python - python是否有一个安全的,用户可编辑的脚本标记,用于像RoR的液体模板?

python - 使用!=获得python while语句

Python - 试图从 Windows 上的 TCP/IP 端口读取数据,但分配错误