curl_easy_perform()失败。SSL对等体证书或SSH远程密钥不正确

问题描述 投票:0回答:1

运行这段代码时,我得到一个错误 "curl_easy_perform()fail.SSL peer certificate or SSH remote key not OK"。SSL peer certificate or SSH remote key was not OK" (SSL对等证书或SSH远程密钥不正确)

#include <stdio.h>
#include <curl/curl.h>

int main(void)
{
    CURL* curl;
    CURLcode res;

    curl = curl_easy_init();
    if (curl) {
        /* First set the URL that is about to receive our POST. This URL can
           just as well be a https:// URL if that is what should receive the
           data. */
        curl_easy_setopt(curl, CURLOPT_URL, "https://www.quandl.com/api/v3/datasets/WIKI/FB/data.json?api_key=MY-CODE-HERE");
        curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);

        /* Perform the request, res will get the return code */
        res = curl_easy_perform(curl);
        if (res != CURLE_OK)
        {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }

        /* always cleanup */
        curl_easy_cleanup(curl);
    }
    return 0;
}

在quandl网站上有一个使用这种GET请求的例子。虽然它使用的是curl.exe,但我不认为它和这个有什么关系。

在quandl网站上,没有任何地方提到如何获得证书或密钥,所以我的初步想法是,他们不允许直接使用libcurl或curl.exe从quandl服务器上检索一些证书。

我也试过google.com,得到的是同样的错误。

有人遇到过这种情况吗?

EDIT

我不想绕过SSL验证。

c++ c ssl libcurl quandl
1个回答
0
投票

我发现你需要在这里下载.pem文件。https:/curl.haxx.sedocscaextract.html。

并添加这些设置...

curl_easy_setopt(curl, CURLOPT_SSL_VERIFYSTATUS, 1);            
curl_easy_setopt(curl, CURLOPT_CAINFO, "PATH TO FILE\\cacert.pem");
curl_easy_setopt(curl, CURLOPT_CAPATH, "PATH TO FILE\\cacert.pem");
© www.soinside.com 2019 - 2024. All rights reserved.