openssl - 为什么 OpenSSL 需要 -CApath 才能使用我的证书?

标签 openssl ssl-certificate

我遇到了一个问题,收到一条错误消息:

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/

相关文章:

linux - OpenSSL 错误和 linux 进程内存管理

java - 如何在java中使用RSA key 加密解密

azure - 我的 Azure 订阅中的私有(private)证书未显示在新应用服务中

SSL 证书 - 根证书中私钥的用途是什么?

ssl - 如何找到我网站的 SSL 证书?

openssl - 将 RSA 公钥转换为 RSA DER

c++ - openssl 和 linux bash 计算之间的 MD5 不匹配

c++ - 使用 OpenSSL 1.1 的 SHA256 HMAC 未编译

ruby-on-rails - 使用 Heroku 和 CloudFront 从 RapidSSL 获得的 SSL 证书

ssl - 用于使用 SSL Pinning 的移动应用程序的 Charles 代理