c - curl NSS -12286 error in TLS handshake -


i getting nss -12286 error while trying load https page using ca certificate using cacertinpem.c curl c code. using cacert.pem file in code alog path. same thing working when try using curl -v "https://sampleserve.com:443",in case ssl taking default ca path "/etc/tls/certs/ca.budle.crt"

but c code not working both default ca location , external path selection of ca aswell.

what reason error(nss -12286).

error: * connect() fiservices.sterlingbankng.com port 443 (#0) *   trying 1.1.1.1... * connection timed out *   trying 1.1.1.2... * connected * connected fiservices.sterlingbankng.com (1.1.1.2) port 443 (#0) * initializing nss certpath: /etc/pki/nssdb *   cafile: ./cacert.pem   capath: ./cacert.pem * nss error -12286 * error in tls handshake, trying sslv3...  /canfi/ http/1.1 host: sampleserver.com accept: */*  * connection died, retrying fresh connect * closing connection #0 * issue request url: 'https://sampleserver.com' * connect() sampleserver.com port 443 (#0) *   trying 1.1.1.1... * connection timed out *   trying 1.1.1.2... * connected * connected sampleserver.com (1.1.1.2) port 443 (#0) * tls disabled due previous handshake failure *   cafile: ./cacert.pem   capath: ./cacert.pem * nss error -12286 * closing connection #0 * ssl connect error 

sample code:

size_t writefunction( void *ptr, size_t size, size_t nmemb, void *stream) {   fwrite(ptr,size,nmemb,stream);                  return(nmemb*size);                    }  static curlcode sslctx_function(curl * curl, void * sslctx, void * parm) {    x509_store * store;    x509 * cert=null;       bio * bio;                                 char * mypem = "-----begin certificate-----\n"\     "-----end certificate-----\n";  //public certificate      }       int main(void)     {    curl * ch;    curlcode rv;    rv=curl_global_init(curl_global_all);    ch=curl_easy_init();    rv=curl_easy_setopt(ch,curlopt_verbose, 1l);    rv=curl_easy_setopt(ch,curlopt_header, 0l);    rv=curl_easy_setopt(ch,curlopt_noprogress, 1l);    rv=curl_easy_setopt(ch,curlopt_nosignal, 1l);    rv=curl_easy_setopt(ch,curlopt_writefunction, *writefunction);    rv=curl_easy_setopt(ch,curlopt_writedata, stdout);    rv=curl_easy_setopt(ch,curlopt_headerfunction, *writefunction);    rv=curl_easy_setopt(ch,curlopt_writeheader, stderr);    rv=curl_easy_setopt(ch,curlopt_sslcerttype,"pem");      rv=curl_easy_setopt (ch, curlopt_capath, "./cacert.pem" );      rv=curl_easy_setopt (ch, curlopt_cainfo, "./cacert.pem" );     rv=curl_easy_setopt(ch,curlopt_ssl_verifypeer,1l);     rv=curl_easy_setopt(ch, curlopt_url, "https://");       rv=curl_easy_perform(ch);               if (rv==curle_ok)                   printf("*** transfer succeeded ***\n");     else                         printf("*** transfer failed ***\n");     rv=curl_easy_setopt(ch,curlopt_ssl_ctx_function, *sslctx_function);     rv=curl_easy_perform(ch);                  if (rv==curle_ok)                   printf("*** transfer succeeded ***\n");                  else                   printf("*** transfer failed ***\n");                   curl_easy_cleanup(ch);      curl_global_cleanup();      return rv;                } 

thanks

ran in php. ran curl on command line -v , found nss -12286 error.

turns out remote server , curl did not have common cypher (nss error codes). added cypher curl object so:

curl_setopt($ocurl, curlopt_ssl_cipher_list, 'rsa_rc4_128_sha'); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -