问题:PHPcurl访问HTTPS网址出错
##环境:
Windows2003,PHP5.4
##问题描述:
访问URL为:https://item.taobao.com/item.htm?id=39881745164
CURL返回错误信息如下:
[errno] => 35
[error] => error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
##相关代码:
function post($url,$post){ $curl = curl_init(); // 启动一个CURL会话 curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); //curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, 'TLSv1'); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($curl, CURLOPT_SSLVERSION, 4); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $tmpInfo = curl_exec($curl); // 执行操作 if (curl_errno($curl)) {echo 'Errno'.curl_error($curl);} curl_close($curl); // 关键CURL会话 $data=$tmpInfo; return $data; // 返回数据 }
s = p o s t ( ′ h t t p s : / / i t e m . t a o b a o . c o m / i t e m . h t m ? i d = 3988174516 4 ′ , ′ ′ ) ; v a r d u m p ( s t r l e n ( s = post('https://item.taobao.com/item.htm?id=39881745164',''); var_dump(strlen(s=post( ′
https://item.taobao.com/item.htm?id=39881745164
′
,
′′
);var
d
ump(strlen(s));
##原因:
item.taobao.com服务器禁用了 SSL 3.0
##解决:
curl添加: curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, ‘TLSv1’);参数
##参考:
http://blog.csdn.net/qq282030166/article/details/44153839
http://www.12345t.com/code/php/20150331/407.html
————————————————