Need some help understanding the ubiquitous cURL 58 error, which is due to, in this case, including a PEM file with the cURL request.
Error 58: unable to set private key file
My code can successfully open the .pem file (see fopen() call) but cURL complains that it cannot set the private key file. Trying to better understand if this something on the client end (me) or something being returned from the host. Pretty sure it’s on my end but not sure what.
Thanks
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->apiURL); $fh = fopen($this->certPath,'a+'); if($fh){ echo "File opened!"; fclose($fh); } else { echo "File not opened"; } curl_setopt($ch, CURLOPT_SSLCERT, $this->certPath); curl_setopt($ch, CURLOPT_POSTFIELDS, trim($SOAPrequest)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); if (curl_error($ch)) { printf("Error %s: %s", curl_errno($ch), curl_error($ch)); } curl_close ($ch); return $result; }
The key:
-----BEGIN CERTIFICATE----- MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL [...] -----END CERTIFICATE-----
Advertisement
Answer
Your file does not contain any private key, only public key.
I think you probably have no reason to use CURLOPT_SSLCERT at all.