我正在尝试对需要客户端证书的第三方API进行测试调用.我使用openssl使用此命令生成了一个新证书:
req -new -newkey rsa:2048 -nodes -out mycsr.csr -keyout mykey.key
Run Code Online (Sandbox Code Playgroud)
然后我给他们发了csr,然后他们把我送回mycert.crt.我将证书和密钥连接在一起:
cat mycert.crt mykey.key > mycertandkey.pem
Run Code Online (Sandbox Code Playgroud)
最后,我将mycert.crt添加到ca-certificates文件夹和ca-certificates.conf并运行"update-ca-certificates --fresh".
现在,我正在尝试使用以下命令从bash进行curl调用:
curl -X GET --cert mycertandkey.pem -H 'Accept-Encoding: gzip,deflate' -H 'Content-Type: application/json' https://api.URL.com
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
curl -X GET --cert mycertandkey.pem --cacert mycert.crt -H 'Accept-Encoding: gzip,deflate' -H 'Content-Type: application/json' https://api.URL.com
Run Code Online (Sandbox Code Playgroud)
和:
curl -X GET --cert mycertandkey.pem --cacert mycert.crt --key mykey.key -H 'Accept-Encoding: gzip,deflate' -H 'Content-Type: application/json' https://api.URL.com
Run Code Online (Sandbox Code Playgroud)
我能想到的其他所有组合.我总是得到错误" 卷曲:(58)无法使用客户端证书(没有找到密钥或错误的密码短语?) ".密钥没有密码.所有证书/密钥文件都具有777权限.
我过去没有太多的证书,我觉得我错过了一些东西,特别是因为我似乎只有一个证书.另一家公司发给我的证书是cacert还是我的客户证书?我是否将私钥连接到错误的证书?
我在网上找到了很多零碎的信息,但是如果有人知道关于这个主题的好教程,我也非常感谢.