服务器证书验证失败。 CAfile:ca.pem CRLfile:none

时间:2015-07-07 12:19:35

标签: c++ linux libcurl

我想在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. CAfile: ca.pem CRLfile: none

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.

1 个答案:

答案 0 :(得分:0)

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