I want to connect to a secured site using PHP cURL. The site owners gave us four files:
And the PEM pass phrase.
$curl_resource = curl_init ();
curl_setopt ( $curl_resource, CURLOPT_URL, $sHost );
curl_setopt ( $curl_resource, CURLOPT_POST, 1 );
curl_setopt ( $curl_resource, CURLOPT_POSTFIELDS, $post_string );
curl_setopt ( $curl_resource, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $curl_resource, CURLOPT_HTTPHEADER, $headerdata);
curl_setopt ( $curl_resource, CURLOPT_HEADER, true);
curl_setopt ( $curl_resource, CURLOPT_SSLCERT , HOMEDIR.'cert/icom-live-ca.pem');
curl_setopt ( $curl_resource, CURLOPT_SSLCERTPASSWD, 'PEM pass phrase');
curl_setopt ( $curl_resource, CURLOPT_SSLKEY, HOMEDIR.'cert/secure.key');
curl_setopt ( $curl_resource, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt ( $curl_resource, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt ( $curl_resource, CURLOPT_SSLCERTTYPE, 'PEM');
I am getting the following error:
Unable to set private key file:'filepath'/secure.key type PEM.
I have not done any settings on my server. Do I need to install/change any setting at client server as well for accessing HTTPS sites?
You should check the file permissions of the files and directory they are in to make sure your program can read them properly. If that doesn't work check the .pem file to make sure the certificate is followed by the cert of its issuer.
See this question and answers for more info: Unable to use libcurl to access a site requiring client authentication
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With