c++ - error in Implementing Client Side https in libcurl? -


i trying implement https client side using libcurl in c++. server using nginx server. have created both server , client certificate using nginx , set respective libcurl parameters (also confused @ many certificate parameter of libcurl). when run program output says problem local ssl certificate. not figure out how solve it. below code:

#include <stdio.h> #include <iostream> #include <curl/curl.h>  using namespace std; int main(void) {   curl *c;   curlcode r;   file *header;   const char *pass = "hawahawa";    static const char *pcert = "/home/asd/certificates/ssl/nginx/client.crt";   static const char *pcacert="/home/asd/certificates/ssl/nginx/ca.crt";   static const char *pheader = "dumpit";    const char *pkey;   const char *pkeytype;     pkey  = "/home/asd/certificates/ssl/nginx/client.pem";   pkeytype  = "pem";     curl_global_init(curl_global_default);    c = curl_easy_init();   if(c) {     /* call write: */     curl_easy_setopt(c, curlopt_url, "https://localhost:8081/consume/topic"); //   curl_easy_setopt(curl, curlopt_headerdata, headerfile);      cout<<"after connecting"<<endl;     { /* dummy loop, break out */        /* cert stored pem coded in file... */       /* since pem default, needn't set pem */       curl_easy_setopt(c, curlopt_sslcerttype, "key");        /* set cert client authentication */       curl_easy_setopt(c, curlopt_sslcert, pcert);        /* sorry, engine must set passphrase          (if key has one...) */ //      if(ppassphrase) //        curl_easy_setopt(curl, curlopt_keypasswd, ppassphrase);       /* if use key stored in crypto engine,          must set key type "eng" */       curl_easy_setopt(c, curlopt_sslkeytype, pkeytype);       curl_easy_setopt(c, curlopt_sslkey, pkey);       /* set file certs vaildating server */       curl_easy_setopt(c, curlopt_cainfo, pcacert);       /* disconnect if can't validate server's cert */       curl_easy_setopt(c, curlopt_ssl_verifypeer, 1l);       /* perform request, res return code */       r = curl_easy_perform(c);       /* check errors */       if(r != curle_ok)           cout<<"entering here";         fprintf(stderr, "curl_easy_perform() failed: %s\n",                 curl_easy_strerror(r));        /* done... */     } while(0);     /* cleanup */     curl_easy_cleanup(curl);   }    curl_global_cleanup();    return 0; } 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -