php - curl sslv3 alert握手失败如何解决?

标签 php ssl curl command-line openssl

我正在尝试在本地 wamp 服务器上的网站上使用 curl。

但是失败并出现错误:

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

我的 curl 版本:

7.30.0

我的 openssl 版本:

OpenSSL/0.9.8y

谢谢。

最佳答案

根据report by SSLabs此站点仅支持 TLS_ECDHE_ECDSA* 密码套件。

OpenSSL/0.9.8y

OpenSSL 0.9.8 不支持任何 ECDHE 密码,因此客户端和服务器之间没有通用密码。这会导致 SSL 握手失败。没有解决方法,但您需要升级 OpenSSL。请注意,这可能还包括重新编译 curl/PHP,以便它们使用更新版本的 OpenSSL。或者您可能会获得更新版本的 WAMP,其中可能包含更新版本的 OpenSSL。

关于php - curl sslv3 alert握手失败如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34578308/

相关文章:

php - 使用外部表单登录 Joomla 1.5(不在 joomla 文件夹中,但在同一台服务器上)

php - 如何将codeigniter中的产品表中的特色数据保存到特色表中

php mysql 回显 |如何从提交表单继承颜色?

php - 为什么我的左连接在我的 php mysql 数据库中不起作用?

c# - 仅允许 TLS 1.0 后仍然可以进行 TLS 1.2 握手

java - Curl Token 请求到 Spring RestTemplate 转换

post - Jenkins 输入管道步骤通过带有 CSRF 的 POST 填充 - 如何?

PHP curl_setopt() CURLOPT_PROGRESSFUNCTION

ssl - 如何签署 API 提供的数据

ruby - 升级 jruby 和 ruby​​mine 版本后无法安装 bundler/gems (SSLError)