cURL / Mailing Lists / curl-library / Single Mail

curl-library

Unable to use libcurl to a site requiring client authentication

From: Jayaprakasam, Kannan <kjayaprakasam_at_informatica.com>
Date: Wed, 25 May 2011 17:36:19 +0530

I'm using the below snipped for setting the certificate and key for
client authentication.

  curl_easy_setopt(curl,CURLOPT_SSLCERT,"clientCert.pem");

    curl_easy_setopt(curl,CURLOPT_SSLCERTPASSWD,"changeit");

    curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");

     curl_easy_setopt(curl,CURLOPT_SSLKEY,"privateKey.pem");

      curl_easy_setopt(curl,CURLOPT_SSLKEYPASSWD,"changeit");

      curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,"PEM");

 

The certificate doesn't have a password, I don't know why on earth the
option SSLCERTPASSWD exists, I just provided a dummy value.

When I run the program on Linux I get an error code of 58 and an error
message

unable to set private key file: 'privateKey.pem' type PEM

 

On Windows however I get

unable to use client certificate (no key found or wrong pass phrase?)

 

It seems to suggest the certificate and the key don't match but I don't
know how. I have extracted both the cert and the key from a p12 file
using openssl commands. I'm attaching the p12 file, certificate and the
key, in case you want to verify the contents.

The command I used to extract the key is

openssl.exe pkcs12 -in client.p12 -nocerts -out privateKey.pem

and the command used to extract the cert is

openssl.exe pkcs12 -in client.p12 -nokeys -out clientCert.pem

 

The p12 file has been successfully used in a browser to access the
client authentication url.

Please help before I shoot myself.

 

Thanks

kannan

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2011-05-25