cURL / Mailing Lists / curl-library / Single Mail

curl-library

LibCURL error codes

From: atul <atul.mehrotra_at_celunite.com>
Date: Wed, 03 Jan 2007 16:37:38 +0530

hii all.. I m using following code snippet for my project. I am facing
the problems in getting proper error code.

//Code Snippet
  CURLcode res;
  char *error;
  if (handle)
    return; // already running

  handle = curl_easy_init();

  curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ::write_cb);
  curl_easy_setopt(handle, CURLOPT_WRITEDATA, this);

  curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, ::header_cb);
  curl_easy_setopt(handle, CURLOPT_WRITEHEADER, this);

  curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1);
  curl_easy_setopt(handle, CURLOPT_MAXREDIRS, 10);
 
  res=curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, TRUE);
  curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, error);
  printf("\n%d\n", res);
  printf ("\n%s\n", error);
  if(res)
     curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, FALSE);

I am using CURLOPT_SSL_VERIFYPEER for the url's whose server certificate
can be authenticated with curl's certificate bundle.
   res=curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, TRUE);

In case the server certificate can not be verified i want curl to go
ahead by skipping the server certificate verification.
  if(res)
     curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, FALSE);

But the value of res is always CURLE_OK whether the server certificate
gets validated or not . According to libcurl error codes i expect it to
return error_code CURLE_SSL_PEER_CERTIFICATE (51) if the peer doesnt get
validated.

Can any tell me that where i am goin wrong????
Received on 2007-01-03