2014-09-24 129 views
2

我試着使用PHP捲曲7.35.0使用下面的代碼訪問以下網頁:PHP捲曲的回報(35):SSL連接錯誤

$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; 

哪個返回如下:

捲曲錯誤( 35):SSL連接錯誤

HTTP代碼:0 內容:

沒有人碰到這個問題之前?

+0

該錯誤代碼意味着超時。您與該主機的網絡連接很可能是錯誤的。 PHP中curl綁定使用的SSL庫可能存在問題。 – JazyK 2014-09-24 06:08:17

+0

如何解決此問題?它看起來像我不能訪問該頁面使用Chrome沒有問題。 – user1029829 2014-09-24 07:20:19

+2

_「有沒有人遇到過這個問題?」_ - [讓我們檢查一下,我們應該嗎?](http://stackoverflow.com/search?q=cURL+error+%2835%29%3A+SSL+connect+error ) – CBroe 2014-09-24 08:44:17

回答

2

添加

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

解決我的問題。

+6

如果您在[php.net](http://php.net/manual/en/function.curl-setopt.php)中向下滾動到** CURLOPT_SSLVERSION **,您可以看到: **將其設置爲2或者3是非常危險的,因爲SSLv2和SSLv3中已知的漏洞。** – machineaddict 2016-03-09 12:01:40

2

通常,這是一個防火牆問題。 SSL連接被網絡管理員禁止。

0

這也解決了我的問題。

我們的環境

PHP的谷歌API客戶端捲曲代碼中5.3.3 的libcurl 7.19.7-46 谷歌的API的PHP客戶端1.1.5

深,httpd的將裏面的死curl_exec()。改變CURLOPT_SSLVERSION從1到3後,一切都很好:)

+2

http://php.net/manual/en/function.curl-setopt.php 注意: 最好的辦法是不要設置這個讓它使用默認值。考慮到SSLv2和SSLv3中已知的漏洞,將其設置爲2或3是非常危險的。 – 2016-09-12 14:07:12