我遇到了一个问题,收到一条错误消息:
Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598) -- Some packages may not be found!
这是我自己定制的 OpenSSL 编译。但是,我的网络浏览器很好地信任该网站。
我尝试过访问 <openssldir>/certs/
并将证书放在那里,然后运行一个小 BASH 脚本以 <hash>.0
格式创建符号链接(symbolic link)为每一个。我在一些地方读到这就是它应该如何工作的
for f in *.pem
do
ln -s "$f" `openssl x509 -hash -noout -in "$f"`.0
done
当我运行时,我能够让它工作:
openssl s_client -showcerts -connect pypi.python.org:443 -CApath .
我得到(被截断)
Start Time: 1399590981
Timeout : 300 (sec)
Verify return code: 0 (ok)
但是,当我运行时:
openssl s_client -showcerts -connect pypi.python.org:443
我得到:
Start Time: 1399591046
Timeout : 300 (sec)
Verify return code: 20 (unable to get local issuer certificate)
为什么只有当我指定-CApath时?
如何让它默认使用这些?
最佳答案
使用此命令,您可以验证证书的来源公司:
openssl s_client -connect pypi.python.org:443
结果:
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert High Assurance CA-3
verify error:num=20:unable to get local issuer certificate
您没有根证书...然后您从以下位置下载 DigiCertAssuredIDRootCA.crt: https://www.digicert.com/digicert-root-certificates.htm
并将其与-CAfile
一起使用:
openssl s_client -connect pypi.python.org:443 -CAfile DigiCertAssuredIDRootCA.crt
现在可以了!
关于openssl - 为什么 OpenSSL 需要 -CApath 才能使用我的证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23554001/