curl_easy_perform () не удалось: сертификат узла SSL или удаленный ключ S SH не в порядке - PullRequest
0 голосов
/ 26 мая 2020

Выполняя этот код, я получаю сообщение об ошибке «curl_easy_perform () failed: SSL peer certificate or S SH remote key was not OK»

#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 есть пример, использующий именно этот Получить запрос. Хотя он использует curl.exe, но я не думаю, что он имеет к этому какое-либо отношение.

Нет, где на веб-сайте quandl упоминается, как получить сертификат или ключ, поэтому мои первоначальные мысли заключаются в том, что они не разрешайте использовать libcurl напрямую ИЛИ curl.exe извлекает некоторые сертификаты с сервера quandl.

Я также пробовал google.com и получил ту же ошибку.

Кто-нибудь сталкивался с этим?

EDIT

Я не хочу обходить проверку SSL.

1 Ответ

0 голосов
/ 26 мая 2020

Я обнаружил, что вам нужно скачать файл .pem здесь https://curl.haxx.se/docs/caextract.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");
...