1

Got from my API providor only .crt file (without private key), i change the name to .pem:

-----BEGIN CERTIFICATE-----
content
-----ENDCERTIFICATE-----

Trying to make an PAI call with a .pem file like this:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("content-type: text/xml"));
curl_setopt($ch, CURLOPT_VERBOSE, '1'); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '2'); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1');
curl_setopt($ch, CURLOPT_SSLCERT, PATH.'/file.pem');

i got this error:

[curl_error_58] => unable to set private key file: 'file.pem' type PEM

my solution was:

i ask from my API provider if they have a private key, and they generate one for me, so the error is very simple i actually needed this private key, without this key "CURLOPT_SSLCERT" just not work.

curl_setopt($ch, CURLOPT_SSLKEY, PATH.'/file.key');
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, '000');
Swissa Yaakov
  • 186
  • 3
  • 15

0 Answers0