cURL Error #:SSL certificate problem: unable to ge
转载
PHP通过cURL访问https时出现SSL certificate problem: unable to get local issuer certificate的解决方法
PHP通过cURL访问https时出现SSL certificate problem: unable to get local issuer certificate的解决方法:只要设置以下两个属性就可以解决。
将 CURLOPT_SSL_VERIFYPEER 设置为 false,
将 CURLOPT_SSL_VERIFYHOST 设置为 false.
代码如下:
<?php
$cURL = curl_init();
$url = 'http://www.51-n.com/';
curl_setopt_array(
$cURL,
array(
CURLOPT_URL => $url,
CURLOPT_REFERER => $url,
CURLOPT_AUTOREFERER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_CONNECTTIMEOUT => 1,
CURLOPT_TIMEOUT => 30,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36'
)
);
//其他代码...
?>