gpt4 book ai didi

ssl - 使用 LibCUrl 的客户端证书

转载 作者:太空宇宙 更新时间:2023-11-03 12:49:00 24 4
gpt4 key购买 nike

我正在使用 libCurl 从远程服务器下载文件。该远程服务器需要客户端证书。以下是我尝试过的选项:

curl_easy_setopt(pCurl, CURLOPT_URL, url);
curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYHOST, 2);
curl_easy_setopt(pCurl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(pCurl, CURLOPT_CERTINFO, 1L);
curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYPEER, 1);
//the following two lines specify the path to my valid client certificate
curl_easy_setopt(pCurl, CURLOPT_CAINFO, "c:\\Delta.p12");
curl_easy_setopt(pCurl, CURLOPT_CAPATH, "c:\\Delta.p12");

当我发出 Https 请求时,我收到一个 403: Forbidden 错误,提示我没有指定所需的凭据。该证书可通过浏览器使用,因此我知道该证书是有效的。

感谢任何帮助完成这项工作的人。谢谢!

最佳答案

如果您收到 403,则表明您已经通过了 SSL 层,因此这表明证书足够好,但服务器在那里谈论其他事情。

但请注意,CURLOPT_CA* 选项用于指定您的 CA 证书包(或路径),因此以上行根本不设置任何客户端证书!

有关显示如何将客户端证书与 libcurl 一起使用的小示例,请参见:

http://curl.haxx.se/libcurl/c/simplessl.html

关于ssl - 使用 LibCUrl 的客户端证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7810432/

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