pip 安装失败 SSL:CERTIFICATE_VERIFY_FAILED on windows

pip installation failing SSL: CERTIFICATE_VERIFY_FAILED on windows

我在 Windows 上使用公司计算机。我有自己的索引,托管在 https 网站上。我知道我可以避免使用 https 使用 trusted-host。但是我想用它。

我正尝试按如下方式安装软件包:

 pip install -i https://pathtoindex/simple/ pkgname

但我收到以下错误:

Could not fetch URL [...] There was a problem confirming the ssl
certificate: [SSL: CERTIFICATE_VERIFY_FAILED]
certificate verify failed (_ssl.c:590) - skipping

我也尝试从 Mozilla 下载我的域的 .pem 认证文件,我尝试了以下命令:

pip --cert dirtocert/cert.pem install -i https://pathtoindex/simple/ pkgname

虽然这也不起作用,仍然会出现相同的错误。

您需要 IT 为您的服务提供的证书的根 CA 证书。它要么是自签名的,要么是由商业提供商提供的。在这两种情况下,您的 IT 部门都应该能够提供证书。

您也可以使用 openssl 查看您的证书:

openssl s_client -showcerts -connect your-domain.com:443

(* 或者,您也可以使用浏览器。单击地址栏中的锁和 select 'details'(或类似内容)..)

"Server certificate" 下应该有一个 "issuer" 部分。如果颁发者是您的公司,您很可能使用的是自签名证书。如果是其他东西(例如 COMODO、StartCom 等),您可以使用他们的根或中间 CA 证书。