Friday, 15 April 2011

php - cURL Error (58): unable to set private key file: '/var/www/work/xml/keys/client.pem' type PEM -



php - cURL Error (58): unable to set private key file: '/var/www/work/xml/keys/client.pem' type PEM -

i getting error, while connecting server using private , public keys.

curl error (58): unable set private key file: '/var/www/work/xml/keys/client.pem' type pem

my private keys contain both key , certificate. has password.

my current code here:

$url="https://example.website.com"; $pemfile = "/var/www/work/xml/keys/server.pem"; $keyfile = "/var/www/work/xml/keys/client.pem"; $requestxml = file_get_contents("net.xml"); $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_http_version, 1.1); curl_setopt($ch, curlopt_port, 443); curl_setopt($ch, curlopt_protocols, curlproto_https); curl_setopt($ch, curlopt_verbose, 1); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_failonerror, 0); curl_setopt($ch, curlopt_sslcert, $pemfile); curl_setopt($ch, curlopt_sslcerttype, 'pem'); curl_setopt($ch, curlopt_sslcertpasswd, 'password'); curl_setopt($ch, curlopt_sslkey, $keyfile); curl_setopt($ch, curlopt_sslkeypasswd, "password"); curl_setopt($ch, curlopt_customrequest, "post"); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_httpheader, array('content-type: text/xml')); curl_setopt($ch, curlopt_postfields, $requestxml); $data = curl_exec($ch); $curl_errno = curl_errno($ch); $curl_error = curl_error($ch); if ($curl_errno > 0) { echo "curl error ($curl_errno): $curl_error\n"; } else { header("content-type: text/xml"); print_r($data); } curl_close($ch);

it appears script can not access $keyfile file correctly. may want double-check script (or process) has right privileges, or modify file permissions.

php ssl curl openssl libcurl

No comments:

Post a Comment