0

我正在尝试连接到需要授权证书的服务,我在我的机器上导入证书,当我通过我的 google chrome 浏览器直接点击服务器时,它给了我完美的结果,但是当我从 php curl 请求中调用这个 URL 时它给了我 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);
4

1 回答 1

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 选项的信息

于 2019-03-26T07:21:50.850 回答