如果证书过期,是否有办法允许PHP连接到https网址?像浏览器中的安全例外。
如果证书有效,则以下代码将无效,但如果证书有效,则以下代码无效。
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://myURL/...,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Basic abcdefghijkl",
"cache-control: no-cache",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
答案 0 :(得分:0)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://myURL/...,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: Basic abcdefghijkl",
"cache-control: no-cache",
),
CURLOPT_SSL_VERIFYPEER => false
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);