2

I am using curl to simply verify if an https site has a valid SSL certificate. My code to check it is :

CURL *curl = curl_easy_init();
CURLcode res;
int verifyresult;
curl_easy_setopt(curl, CURLOPT_URL, urlHttps.c_str());
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_SSL_VERIFYRESULT, &verifyresult);
cout <<  "Verify https : " << verifyresult << endl;
curl_easy_cleanup(curl);

The site I am checking has a valid certificate but curl_easy_getinfo() return 20 instead of 0. And the thing is also that the 20 return code doesn't exist : https://curl.haxx.se/libcurl/c/libcurl-errors.html So what is this 20 error code and why doesn't it returns a 0 error code?

  • It won't probably change the result but `verifyresult` should be a `long`... – klaus Feb 21 '18 at 16:47
  • @klaus I tested with a long first then put an int and the result was the same – Louis de Bussac Feb 23 '18 at 19:25
  • Have you tried this solution: https://stackoverflow.com/questions/290996/http-status-code-with-libcurl] ? – klaus Feb 23 '18 at 19:33
  • @klaus will it work for an https status code? And this still doesn't tell what the 20 error code coresponds to. – Louis de Bussac Feb 23 '18 at 19:38
  • `curl_easy_getinfo` is not returning 20, you are not checking what it returns. Perhaps you meant `curl_easy_getinfo` sets `verifyresult` to 20. In this case https://curl.haxx.se/libcurl/c/libcurl-errors.html is not the place to find what 20 means. https://curl.haxx.se/libcurl/c/CURLINFO_SSL_VERIFYRESULT.html is, but sadly it contains no such information. It actually contains an example which seems to be the exact opposite of what `verifyresult` means... – Michał Trybus Mar 19 '18 at 10:52
  • yes it is wat I meant. And so their is no response to what this 20 in the verifyresult is? Is their a better way to verify if the site checked has a valid SSL certificate to have an apropriate response code? – Louis de Bussac Apr 02 '18 at 20:24

0 Answers0