卷曲请求通过TLS v1.0

时间:2017-10-02 19:00:06

标签: php curl

使用以下代码通过TLS v1.0发送请求。

$url = "https://example.com";
$input_segment = "";

$data = array('InputSegments'=>$input_segment, 'cmdSubmit'=>'Submit');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
curl_setopt($ch, CURLOPT_PORT, "443");
curl_setopt($ch, CURLOPT_SSLVERSION, 4);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                                        'Content-Type: application/x-www-form-urlencoded'
                                        ));
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$err_no = curl_errno($ch);
$err = curl_error($ch);
curl_close($ch);
var_dump($response);

错误

  

错误#:SSL读取:错误:00000000:lib(0):func(0):reason(0),errno 104

看起来仍在使用SSL。如何在PHP中通过TLSv1.0发送curl请求?

1 个答案:

答案 0 :(得分:0)

强制使用TLS 1.0,我认为将CURLOPT_SSLVERSION设置为CURL_SSLVERSION_TLSv1_0已足够