curl error: SSL certificate problem: unable to get local issuer certificate

  • Post author:
  • Post category:其他


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
//将https 的ssl验证相关项改为false
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSLVERSION, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) {
    return $k . ': ' . $v;
}, array_values($headers), array_keys($headers)));
if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) {
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($bodyParams));
}

$data = curl_exec($ch);
if (curl_errno($ch)) {
    echo "Error: " . curl_error($ch);
} else {
	echo '<pre>';
    var_dump(json_decode($data,true));
}
curl_close($ch);



版权声明:本文为lfbin5566原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。