Im using the below to install 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 does not have a password, I do not know why the SSLCERTPASSWD option actually exists, I just provided a dummy value. When I run the program on Linux, I get error code 58 and the error message could not install the private key file: type privateKey.pem PEM
On Windows, however, I get a failed to use a client certificate (key not found or wrong phrase?)
It seems that the certificate and the key do not match, but I do not know how to do this. I extracted both cert and key from the p12 file using openssl commands. 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 certificate is
openssl.exe pkcs12 -in client.p12 -nokeys -out clientCert.pem
The p12 file was successfully used in the browser to access the client authentication URL. Help before shooting yourself.
Edit: Here is the proof that the private key and certificate match each other:
[ debugbld@nagara ~/curlm]$ openssl x509 -noout -modulus -in clientCert.pem | openssl md5 d7207cf82b771251471672dd54c59927 [ debugbld@nagara ~/curlm]$ openssl rsa -noout -modulus -in privateKey.pem | openssl md5 Enter pass phrase for privateKey.pem: d7207cf82b771251471672dd54c59927
So why is this not working?