具有相互认证的cUrl

具有相互认证的cUrl,curl,ssl-certificate,mutual-authentication,Curl,Ssl Certificate,Mutual Authentication,我正在尝试对第三方服务器进行卷曲。他们为我提供了一个p12文件,我将其安装在浏览器中。使用浏览器时,我从服务器获得响应。从linux终端执行卷曲时,我会收到握手错误 我将.p12提取到密钥和证书,然后运行以下命令: curl-key client.key-cert client.crt-X GET-vhttps://x.x.x.x:xxxx/folder/endpoint 并得到以下回复: Note: Unnecessary use of -X or --request, GET is alre

我正在尝试对第三方服务器进行卷曲。他们为我提供了一个p12文件,我将其安装在浏览器中。使用浏览器时,我从服务器获得响应。从linux终端执行卷曲时,我会收到握手错误

我将.p12提取到密钥和证书,然后运行以下命令:

curl-key client.key-cert client.crt-X GET-vhttps://x.x.x.x:xxxx/folder/endpoint

并得到以下回复:

Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying x.x.x.x...
* TCP_NODELAY set
* Connected to x.x.x.x (x.x.x.x) port xxxx (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS alert, Server hello (2):
* SSL certificate problem: unable to get local issuer certificate
* stopped the pause stream!
* Closing connection 0
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
我需要在某处添加自签名证书吗?我觉得我错过了什么。如前所述,它可以从导入证书的浏览器中工作,因此我确信他们的证书没有问题。我知道我遗漏了一些东西


谢谢,

您的错误消息是:

无法获取本地颁发者证书

这意味着curl无法从信任存储中找到签署服务器证书的颁发者CA的证书:

/etc/ssl/certs/ca-certificates.crt


您只需下载CA证书并将其添加到信任存储。

您的错误消息是:

无法获取本地颁发者证书

这意味着curl无法从信任存储中找到签署服务器证书的颁发者CA的证书:

/etc/ssl/certs/ca-certificates.crt

您所要做的就是下载CA证书并将其添加到信任存储。

是的,如果已下载证书,您需要在curl命令中添加-cacert选项,或者在我的示例中添加自签名证书

curl-key client.key-cert client.crt-cacert bundle.pem-X GET-vhttps://x.x.x.x:xxxx/folder/endpoint.

bundle.pem包含server.crt和rootCA.crt

cat server.crt rootCA.crt>>bundle.pem

是的,如果您下载了curl命令,或者在我的示例中是自签名证书,则需要将-cacert选项添加到curl命令中

curl-key client.key-cert client.crt-cacert bundle.pem-X GET-vhttps://x.x.x.x:xxxx/folder/endpoint.

bundle.pem包含server.crt和rootCA.crt

cat server.crt rootCA.crt>>bundle.pem