PHP curl 返回 (35):SSL 连接错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26009611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP curl returns (35): SSL connect error
提问by user1029829
Im trying to visit the following page using php curl 7.35.0 using the following code:
我尝试使用以下代码使用 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;
Which returns the following:
返回以下内容:
cURL error (35): SSL connect error
cURL 错误 (35):SSL 连接错误
http code: 0 content:
http 代码:0 内容:
Did anyone run into this problem before?
以前有人遇到过这个问题吗?
回答by user1029829
Adding
添加
curl_setopt($this->ch, CURLOPT_SSLVERSION , 3);
solve my issue.
解决我的问题。
回答by Gucci Koo
usually, this is an firewall issue. SSL connection is banned by network administrator.
通常,这是防火墙问题。网络管理员禁止 SSL 连接。
回答by Jorge Wander Santana Ure?a
回答by Glene
This solved my issue as well.
这也解决了我的问题。
Our environment
我们的环境
PHP 5.3.3 libcurl 7.19.7-46 google-api-php-client 1.1.5
PHP 5.3.3 libcurl 7.19.7-46 google-api-php-client 1.1.5
Deep within the Google API Client Curl code, httpd would die inside the curl_exec(). After changing CURLOPT_SSLVERSION from 1 to 3, all is well :)
在 Google API 客户端 Curl 代码的深处,httpd 会在 curl_exec() 中消失。将 CURLOPT_SSLVERSION 从 1 更改为 3 后,一切都很好:)