gpt4 book ai didi

cUrl 相互认证

转载 作者:行者123 更新时间:2023-12-04 12:43:01 26 4
gpt4 key购买 nike

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

我将 .p12 提取到 key 和证书,然后运行以下命令:
curl --key client.key --cert client.crt -X GET -v https://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.

我需要在某处添加自签名证书吗?我觉得我错过了一些东西。如前所述,它可以在我导入证书的浏览器中运行,所以我确信他们的证书没有问题。我知道我错过了一些东西。

谢谢,

最佳答案

是的,您需要添加 --cacert如果您下载了 curl 命令的选项或自签名证书(在我的情况下)
curl --key client.key --cert client.crt --cacert bundle.pem -X GET -v https://x.x.x.x:xxxx/folder/endpoint .
bundle.pem有 server.crt 和 rootCA.crt。
cat server.crt rootCA.crt >> bundle.pem

关于cUrl 相互认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55561615/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com