php - IPN 监听器突然停止工作

标签 php curl paypal ssl-certificate paypal-ipn

我的paypal IPN listener用了一年多了,今天突然报错停止了

cURL error: [60] SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

我的 curl 设置是

protected function curlPost($encoded_data) {
    if ($this->use_ssl) {
        $uri = 'https://'.$this->getPaypalHost().'/cgi-bin/webscr';
        $this->post_uri = $uri;
    } else {
        $uri = 'http://'.$this->getPaypalHost().'/cgi-bin/webscr';
        $this->post_uri = $uri;
    }

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_CAINFO, 
                dirname(__FILE__)."/cert/api_cert_chain.crt");
    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $this->follow_location);
    curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);


    $this->response = curl_exec($ch);
    $this->response_status = strval(curl_getinfo($ch, CURLINFO_HTTP_CODE));

    if ($this->response === false || $this->response_status == '0') {
        $errno = curl_errno($ch);
        $errstr = curl_error($ch);
        throw new Exception("cURL error: [$errno] $errstr");
    }
}

我尝试使用来自 http://curl.haxx.se/ca/cacert.pem 的最新证书作为 api_cert_chain.crt 正如许多与但这并没有改变任何东西。

这可能是什么原因?

最佳答案

添加 curl_setopt($ch, CURLOPT_SSLVERSION, 4); 解决了这个问题。

关于php - IPN 监听器突然停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29232961/

相关文章:

php - 在 mysql 或 php 中使用 utf 字符排序?最佳解决方案

PHP CodeIgniter WHERE 子句语句

php - 如何读取/查看存储的数组[] mysql php

java - spring mvc 的 Curl POST 请求给出 405 方法 'POST' 不支持

ios - Paypal Kinvey 集成

php - 服务器错误5006:供应商未指定重定向URL,但已指定URL

php - 从双重缩短的 URL 获取最终 URL (t.co -> bit.ly -> final)

rest - 这里 API 返回 Unrecognized Kid Null 错误

html - 通过 PayPal 传递选项

asp.net - 将 PayPal 凭据存储在共享主机上的 Web 应用程序 (asp.net) 中