问题描述
我正在使用 curl 来验证 PayPal IPN,但它抛出错误:SSL 证书问题:无法获得本地颁发者证书
.相同的代码在开发服务器上工作,当我移动到客户端服务器时它不起作用.
I am using curl to verify the PayPal IPN but it throws error: SSL certificate problem: unable to get local issuer certificate
. The same code is working on development server and when I moved to client server it is not working.
我是否需要购买 ssl 认证才能通过 PayPal 快速结账或我的编码部分的任何更改或需要在服务器上进行的任何设置进行付款.Curl 已在服务器上启用.任何帮助将不胜感激.
DO I need to purchase ssl certification in order to make payment via PayPal express checkout or any change in my coding part or any setting need to make on server.Curl is already enabled on server. Any help will be appreciated.
下面是我的代码,它是一个简化的测试页面:
My code below, and its a reduced test page for this:
$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);
}
推荐答案
你告诉 cURL 验证 SSL 连接,但你没有告诉它验证什么;
You're telling cURL to validate the SSL connection but you're not telling it what to validate against;
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
确保您通过添加以下内容指向要信任的 CA 的最新列表:
Make sure you point to an up-to-date list of CA's to trust by adding:
curl_setopt($ch, CURLOPT_CAPATH, "./cacert.pem");
如果您自己没有最新的 cacert 列表,我建议您下载 cURL 维护者提供的列表:cacert.pem.
If you don't have an up-to-date cacert list yourself, I'd recommend downloading the one supplied by the cURL maintainer: cacert.pem.
这篇关于PayPal IPN:无法获得本地发行人证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!