IPN 监听器突然停止工作

Posted

技术标签:

【中文标题】IPN 监听器突然停止工作【英文标题】:IPN listener suddenly stopped working 【发布时间】:2015-05-27 18:48:29 【问题描述】:

我的 paypal IPN 监听器已经工作了一年多,今天它突然停止工作并出现错误

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,正如许多与此相关的答案中所建议的那样,但它没有改变任何东西。

这可能是什么原因?

【问题讨论】:

【参考方案1】:

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

【讨论】:

我猜这可能取决于您的证书文件中的内容 - 它不适用于我的。根据以下答案下载新的证书文件为我解决了这个问题 - ***.com/questions/29235389/…

以上是关于IPN 监听器突然停止工作的主要内容,如果未能解决你的问题,请参考以下文章

PayPal IPN 已停止工作

我的 PayPal 脚本突然停止验证 SSL 证书

PayPal IPN 突然停止流入

使用 SQL Server AlwaysOn 创建侦听器突然停止工作

PayPal IPN 停止工作 422 错误

在 paypal IPN 监听器中使用 HTTPS