我在使用curl时遇到了问题,无法对使用TLS1.2的HTTPS url进行操作。我的curl操作是将登录数据发布到网站上,并将其保存在cookiefile中。我收到的错误消息是:
error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error
我尝试将 VERIFYPEER
和 VERIFYHOST
设置为0,但似乎没有起作用,你有什么建议吗?我使用的版本如下:
- OpenSSL版本是0.9.8b
- CURL版本是7.24.0
- PHP版本是5.3
$setuplogin = curl_init();
curl_setopt ($setuploginurl, CURLOPT_URL, $url);
curl_setopt ($setuploginurl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt ($setuploginurl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt ($setuploginurl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt ($setuploginurl, CURLOPT_SSLVERSION, 'CURL_SSLVERSION_TLSv1_2');
curl_setopt ($setuploginurl, CURLOPT_POSTFIELDS, 'username=uname&password=pword&act=login&submit=Login');
curl_setopt ($setuploginurl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36");
curl_setopt (setuploginurl, CURLOPT_TIMEOUT, 60);
curl_setopt ($setuploginurl, CURLOPT_COOKIESESSION, TRUE);
curl_setopt ($setuploginurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($setuploginurl, CURLOPT_HEADER, 1);
curl_setopt ($setuploginurl,CURLOPT_ENCODING,"gzip");
curl_setopt ($setuploginurl, CURLOPT_POST, true);
curl_setopt ($setuploginurl, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt ($setuploginurl, CURLOPT_FRESH_CONNECT , 1);
$loginp= curl_exec($setuploginurl);
if ($loginp === FALSE) {
die(curl_error($setuploginurl));
}
curl_close ($setuploginurl);
var_dump ($loginp);