curl错误:无法设置私钥文件

时间:2014-07-04 10:16:23

标签: php curl

尝试实施Authipay付款网关。已在同一目录中成功安装证书。

我使用realpath()得到以下错误: -

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

没有realpath(): -

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

我正在尝试下面的代码: -

$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);
用胶水搜索并在堆栈上搜索很多,但仍然坚持这个问题。任何帮助都会很明显

1 个答案:

答案 0 :(得分:1)

排队:

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

您在(

之后找不到括号realpath

所以你的行必须如下:

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