openssl验证错误:num=20:无法获取本地颁发者证书

2024-06-28 19:54:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道这个问题已经有很多答案了,但我已经尝试了所有的方法,我仍然不能让这个工作。我只是想让我的本地主机使用https。如有任何帮助/提示,将不胜感激,谢谢!在

我运行的是python2.7和openssl1.1.0f和macos10.13highsierra。在

我所尝试/知道的:

  • 我在密钥链访问中标记了我的自签名根证书 一如既往的信任。在
  • 从我读到的,我理解错误20意味着它找不到我的根证书,但是它在我的密钥链访问中,所以我不确定我在哪里丢失了
  • 我也读过/etc/ca-证书.conf,并确保证书在那里,我已经检查过了,但它没有,但我试着把它放在那里更新ca证书,它也没有起作用。根据我的理解,在keychain访问中拥有根CA就足够了?
    • 基本上,我在keychain中有我的自签名根证书,在python文件中有我的密钥和证书,但是当我curl localhost时,我会收到 curl: (60) SSL certificate problem: unable to get local issuer certificate

我也尝试了所有这些方法,得到了相同的输出:

openssl s_client -connect localhost:5000

openssl s_client -connect localhost:5000 -CAfile rootCA.pem

openssl s_client -connect localhost:5000 -CApath /etc/ssl/certs/

输出:

openssl s_client -CApath /etc/ssl/certs/ -connect localhost:5000
CONNECTED(00000003)
depth=0 C = US, ST = California, L = San Fran, O = My org, OU = My unit, CN = localhost
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 C = US, ST = California, L = San Fran, O = My org, OU = My unit, CN = localhost
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
 0 s:/C=US/ST=California/L=San Fran/O=My org/OU=My unit/CN=localhost
   i:/C=US/ST=California/L=San Fran/O=My org/OU=My unit/CN=localhost
---
Server certificate
-----BEGIN CERTIFICATE-----
certificate stuff...
-----END CERTIFICATE-----
subject=/C=US/ST=California/L=San Fran/O=My org/OU=My unit/CN=localhost
issuer=/C=US/ST=California/L=San Fran/O=My org/OU=My unit/CN=localhost
---
No client certificate CA names sent
Peer signing digest: SHA512
Server Temp Key: X25519, 253 bits
---
.
.
.
. other info....

    Start Time: 1530725381
    Timeout   : 7200 (sec)
    Verify return code: 21 (unable to verify the first certificate)
    Extended master secret: yes

Tags: orgclientlocalhostmyunitoucertificatecn