我正在尝试连接到需要授权证书的服务,我在计算机上导入了证书,当我用Google chrome浏览器直接在服务器上命中它时,这给我带来了完美的结果,但是当我从php curl请求它给我sslv3警报握手失败错误。 (错误:14094410:SSL例程:ssl3_read_bytes:sslv3警报握手失败)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://example.com",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_CIPHER_LIST => SSLv3,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSLVERSION => 7,
CURLOPT_SSLVERSION => 7,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
var_dump($response);
var_dump($err);
答案 0 :(得分:0)
您需要将证书导入CURL并设置任何所需的选项
$caFile = "ca.pem";
$keyFile = "key.pem";
$certFile = "client.pem";
$certPass = "xxxxxx";
curl_setopt($ch, CURLOPT_CAINFO, $caFile);
curl_setopt($ch, CURLOPT_SSLKEY, $keyFile);
curl_setopt($ch, CURLOPT_SSLCERT, $certFile);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $certPass);
您可以查看每个CURL选项from here
的信息