【发布时间】:2016-04-19 15:39:32
【问题描述】:
我有以下代码:
<?php
$cookie_file_path = "cookie.txt"; //
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'theurl');
curl_setopt($ch, CURLOPT_POSTFIELDS,'blocPnr_textField_labelNom='.urlencode('www').'&blocPnr_textField_labelPnr='.urlencode('xxx').'&blocPnr_valider=Submit');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSLVERSION,3);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_setopt($ch, CURLOPT_REFERER, "theurl");
$page = curl_exec($ch);
var_dump($page);
echo 'error:' . curl_error($ch);
?>
它给了我以下错误:
bool(false) 错误:错误:14094410:SSL 例程:SSL3_READ_BYTES:sslv3 警报握手失败
我不知道 pb 是从哪里来的。我在 Google 和 S/O 上查找了类似的错误消息,但没有找到任何解决方案。
【问题讨论】:
-
你确定是
sslv3吗? -
我怎么知道?我可以尝试哪些不同的版本?我看了这个 (curl.haxx.se/libcurl/c/CURLOPT_SSLVERSION.html) 但不确定我是否理解该输入什么
-
这是一个
CURL_SSLVERSION_TLSv1改用这个。 -
有效!!非常感谢
-
curl 的文档你可以在这里找到它:php.net/manual/en/function.curl-setopt.php
标签: php ssl curl handshake sslhandshakeexception