'CURLE_PEER_FAILED_VERIFICATION error in c program

This code outputs 60 which corresponds to CURLE_PEER_FAILED_VERIFICATION in the error code in the libcurl docs

The remote server's SSL certificate or SSH md5 fingerprint was deemed not OK.

I am assuming that my program can't find the public key of the website that it reaches (google.com in this case) or it does not know where it's own public key is

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



int main()
{

    CURL *curl = curl_easy_init();
    if(curl) {
      CURLcode res;
      curl_easy_setopt(curl, CURLOPT_URL, "https://google.com");
      res = curl_easy_perform(curl);
      printf("%d", res);
      curl_easy_cleanup(curl);
    }
    else
        printf("Done");
    return 0; 
}

The program compiled using msys2 MINGW64 The only output I got is 60



Solution 1:[1]

This provides a workaround for this issue but this still does not fix the issue since it does not check the certificate

curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);

the workaround simply turns off SSL verification for peer and host

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 packet_sniffer