I get this error : Fatal error: Curl failed with error #58: unable to use client certificate (no key found or wrong pass phrase?)
I have a script that extracts the certificate information from a .p12 file. I thought this was the problem to start, however I used this to paste the contents of my generated .pem file : https://www.sslshopper.com/certificate-decoder.html and it decodes/sees it all fine. So I assume the .pem is ok.
$ch = curl_init();
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSLCERT, 'cert.pem');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
// converting
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
if($response === false){
throw new Exception(curl_error($ch), curl_errno($ch));
}
The pem file is as such :
-----BEGIN CERTIFICATE-----
<cert bla bla>
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
<key bla bla>
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
<cert bla bla>
-----END CERTIFICATE-----–
Any suggestions welcomed.
Thanks