Rakesh Sharma
Rakesh Sharma

Reputation: 13728

curl error: unable to set private key file

Trying to implement Authipay payment gateway. Installed certificate successfully in the same directory.

i am getting below error with use of realpath():-

unable to set private key file: 'D:\xampp\htdocs\authipay\WS13205400304._.1.key' type PEM

without realpath() :-

unable to use client certificate (no key found or wrong pass phrase?)

i am trying below code:-

$ch = curl_init("https://test.ipg-online.com/ipgapi/services");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "user:pass");
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CAINFO, realpath("geotrust.pem"));
curl_setopt($ch, CURLOPT_SSLCERT, realpath("WS13205400304._.1.pem"));
curl_setopt($ch, CURLOPT_SSLKEY, realpath("WS13205400304._.1.key"));
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "ckp_".time());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
print_r(curl_getinfo($ch));
echo curl_error($ch);
curl_close($ch);

googled and searching on stack a lot but still stuck with this problem. Any help would be appreciable

Upvotes: 0

Views: 2014

Answers (1)

pes502
pes502

Reputation: 1597

In line:

curl_setopt($ch, CURLOPT_SSLKEY, realpath"WS13205400304._.1.key"));
                                         ^
                                        HERE

you have got missing bracket ( after word realpath

So your line must look like:

curl_setopt($ch, CURLOPT_SSLKEY, realpath("WS13205400304._.1.key"));

Upvotes: 1

Related Questions