【问题标题】:PHP curl returns (35): SSL connect errorPHP curl 返回 (35): SSL 连接错误
【发布时间】:2014-09-24 06:01:36
【问题描述】:

我正在尝试使用 php curl 7.35.0 使用以下代码访问以下页面:

    $this->ch = curl_init();
    curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 3000);
    curl_setopt($this->ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36");
    curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($this->ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    curl_setopt($this->ch, CURLOPT_TIMEOUT, 3600);
    curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($this->ch, CURLOPT_URL, 'https://asp.reflexion.net/login');
    curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
    $content  = curl_exec($this->ch);
    $httpCode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
    if ($errno    = curl_errno($this->ch))
    {
        $error_message = curl_strerror($errno);
        echo "cURL error ({$errno}):\n {$error_message}";
    }
    echo "<br>";
    echo "http code: " . $httpCode . "<br>";
    echo "content: " . $content;

返回以下内容:

cURL 错误 (35):SSL 连接错误

http 代码:0 内容:

以前有人遇到过这个问题吗?

【问题讨论】:

  • 该错误代码表示超时。您与该主机的网络连接很可能出现故障。 PHP 中 curl 绑定使用的 SSL 库可能存在问题。
  • 我该如何解决这个问题?看起来我无法使用 Chrome 毫无问题地访问该页面。
  • “以前有人遇到过这个问题吗?” - let's check, shall we?

标签: php ssl curl


【解决方案1】:

添加

curl_setopt($this->ch, CURLOPT_SSLVERSION , 3);

解决我的问题。

【讨论】:

  • 如果您在php.net 向下滚动到 CURLOPT_SSLVERSION,您会看到:鉴于 SSLv2 和 SSLv3 中的已知漏洞,将其设置为 2 或 3 非常危险。
【解决方案2】:

通常,这是防火墙问题。 SSL 连接被网络管理员禁止。

【讨论】:

  • 你能解释一下如何解决这个问题吗?
【解决方案3】:

这对我有用: yum update nss

来源:https://serverfault.com/a/642203

【讨论】:

  • 这里是Centos 6.4,这已经为我解决了。
【解决方案4】:

这也解决了我的问题。

我们的环境

PHP 5.3.3 libcurl 7.19.7-46 google-api-php-client 1.1.5

在 Google API 客户端 Curl 代码的深处,httpd 会在 curl_exec() 中死掉。将 CURLOPT_SSLVERSION 从 1 更改为 3 后,一切都很好:)

【讨论】:

猜你喜欢
  • 2016-08-15
  • 2019-02-13
  • 2018-06-16
  • 2014-03-20
  • 1970-01-01
  • 1970-01-01
  • 2016-09-16
  • 2017-07-16
  • 1970-01-01
相关资源
最近更新 更多