2016-01-03 127 views
1

我想在本地的wamp服務器上的網站上使用捲曲。如何解決curl ssl v3警報握手失敗?

然而,它失敗,出現錯誤:

error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure 

這裏是我的代碼:

$url = sprintf('http://thepiratebay.se/search/%s/0/99/%d/', urlencode($keyword), $category); 

curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile); 
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); 
curl_setopt($ch, CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); 
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/cert/cacert.pem"); 

我嘗試添加以下線路上site的建議:

curl_setopt($ch, CURLOPT_SSLVERSION, 3); 
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'SSLv3'); 

但它給出了一個新的錯誤:

error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure 

我的PHP版本:

5.4.16 

我捲曲版本:

7.30.0 

我OpenSSL的版本:

OpenSSL/0.9.8y 

感謝。

回答

4

根據report by SSLabs該網站僅支持TLS_ECDHE_ECDSA *密碼套件。

OpenSSL/0.9.8y 

OpenSSL的0.9.8不支持任何ECDHE密碼,因此有客戶端和服務器之間沒有共同的密碼。這會導致SSL握手失敗。沒有解決方法,但您需要升級您的OpenSSL。請注意,這可能也包括重新編譯curl/PHP,以便他們使用更新版本的OpenSSL。或者你可能會得到一個更新版本的WAMP,它可能會包含更新版本的OpenSSL。

+0

謝謝你的解釋。我有一個安裝了OpenSSL 1.0.1e-fips的unix盒子。我的同樣的代碼就像一個魅力。乾杯。 – vrtech77