0

Using this code (pasted from this tutorial), I get a successful PayPal DoDirectPayment method execution. Note that CURLOPT_SSL_VERIFYPEER is set to FALSE.

However when I set the normal value (CURLOPT_SSL_VERIFYPEER = TRUE) I get no response from PayPal, not even a failure response, despite the fact that my code operates on a server with a working SSL certificate (all pages work with HTTPS URLs).

Anybody knows what could cause this problem ?

4

1 回答 1

0

如果您使用的是有效证书并且问题仍然存在,您可能需要仔细检查您是否以有效格式(X.509 证书 PEM)保存了 CA。我看到您已将 CA 导出到名为 cacert.pem 的文件中 - 确保此文件有效,并且 curl 确实能够检索此文件(有效路径等)

您可以尝试再次导出证书 - 从浏览器(即:firefox),这可以通过在浏览器(即:Firefox)中访问 PayPal https url 来完成 - 并查看证书然后导出它。(确保使用前面所述的正确格式 - X.509 证书 PEM)。

保存 CA 后,您将其传递给 CURLOPT_CAINFO 参数,因为您已经拥有:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/CAcerts/BuiltinObjectToken-EquifaxSecureCA.crt");

有关更详细的解释,请访问这篇精彩的文章: http ://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

引用关于证书的最后一部分:

如果您有 CA 证书,但它不是 PEM 格式(即它是二进制或非 Base64 编码的 DER 格式),您需要使用 OpenSSL 之类的东西将其转换为 PEM 格式.

编辑- 如果导出证书后出现错误,您还可以尝试使用 X.509 证书 PEM(带链)保存证书

于 2013-02-20T19:01:08.467 回答