gpt4 book ai didi

c++ - 服务器证书验证失败。 CAfile : ca. pem CRL 文件:无

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:28:11 24 4
gpt4 key购买 nike

我想在 C++ 中使用 libcurl 和 openssl 进行 https 测试。 我有以下代码:

curl_easy_setopt(mEasyHandle, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(mEasyHandle, CURLOPT_SSL_VERIFYHOST, 2L);
result = curl_easy_setopt(mEasyHandle, CURLOPT_CAINFO , "ca.pem");

我有一台监听 192.168.0.101:4443 的 Windows 服务器。当从 Visual Studio 运行程序时,证书验证有效,但在 Linux 上我收到错误 server certificate verification failed。 CA文件:ca.pem CRL文件:无

ca.pem 中,我将生成的内容放入服务器的证书中(在 Windows 上测试有效,在 Linux 上无效)。

* Trying 192.168.0.101...
* Connected to 192.168.0.101 (192.168.0.101) port 4443 (#0)
* found 1 certificates in ca.pem
* server certificate verification failed. CAfile: ca.pem CRLfile: none
* Closing connection 0

更新:

我有一个文件夹 /etc/ssl/certs,其中包含很多 ca 证书文件。我已将 ca.pem 复制到 /etc/ssl/certs 并运行生成的 update-ca-certificates输出:

Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d....done.

最佳答案

我已经解决了这个问题。实际上是证书问题。代码有效,但机器上的时间戳是在证书生成之前。

关于c++ - 服务器证书验证失败。 CAfile : ca. pem CRL 文件:无,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31268401/

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