简体   繁体   English

在Visual Studio中使用Libcurl发出HTTPS请求时遇到问题

[英]Trouble making a HTTPS request with Libcurl in Visual Studio

I have a Web Service hosted on Azure, that is secured under SSL via a Self Signed Certificate. 我在Azure上托管了一个Web服务,该服务通过自签名证书在SSL的保护下。

I am trying to connect to it with the following code 我正在尝试使用以下代码连接到它

CURL *curl;
CURLcode res;

curl = curl_easy_init();

curl_easy_setopt(curl, CURLOPT_URL, "https://XXXXXXXX.cloudapp.net/XXXXXX.svc/getFilms");
curl_easy_setopt(curl, CURLOPT_CAPATH, "C:\\Users\\Jordan\\Desktop\\Jordan-8.pem");
curl_easy_setopt(curl, CURLOPT_CAINFO, "C:\\Users\\Jordan\\Desktop\\Jordan-8.pem");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

curl_easy_perform(curl);

I then receive the following error 然后,我收到以下错误

* Connected to XXXXXXXXX.cloudapp.net
* successfully set certificate verify locations:
* CAfile: C:\Users\Jordan\Desktop\Jordan-8.pem
CApath: C:\Users\Jordan\Desktop\Jordan-8.pem
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
* Closing connection #0
* Peer certificate cannot be authenticated with known CA certificates

Is there anything I am doing wrong? 我做错了什么吗? I have researched online for quite some time but came up with nothing. 我已经在网上研究了一段时间,但一无所获。

Usually when this happens it's because the SSL certificates used by libcurl are outdated. 通常,发生这种情况是因为libcurl使用的SSL证书已过时。 I recommend switching to the cert bundle here to see if you have better luck with it. 我建议在这里切换到证书捆绑包 ,看看您是否有更好的运气。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM