Dij*_*ijo 7 perl ssl curl paypal
我使用curl来验证PayPal IPN,但它会抛出错误:SSL certificate problem: unable to get local issuer certificate.相同的代码正在开发服务器上,当我移动到客户端服务器时,它无法正常工作.
我是否需要购买ssl认证才能通过PayPal快速结账或我的编码部分的任何更改或任何需要在服务器上进行的设置付款.服务器上已启用了Cookie.任何帮助将不胜感激.
我的代码如下,以及针对此的简化测试页:
$req = HAVING PARAMETERS FROM PAYPAL;
$ch = curl_init("https://www.sandbox.paypal.com/cgi-bin/webscr");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
curl_exec($ch);
if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch);
}
Run Code Online (Sandbox Code Playgroud)
Rob*_*ert 11
您告诉cURL验证SSL连接,但您没有告诉它要验证什么;
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
Run Code Online (Sandbox Code Playgroud)
确保通过添加以下内容指向要信任的CA的最新列表:
curl_setopt($ch, CURLOPT_CAPATH, "./cacert.pem");
Run Code Online (Sandbox Code Playgroud)
如果您自己没有最新的cacert列表,我建议您下载cURL维护者提供的那个:cacert.pem.
小智 5
你想要CURLOPT_CAINFO(指向一个PEM文件)不是CURLOPT_CAPATH(指向包含PEM文件的目录).
curl_setopt($ch, CURLOPT_CAINFO, "./cacert.pem");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15331 次 |
| 最近记录: |