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.congcong.us/';
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'
        )
);
//其他代码...
?>

虽然请求OK了,但是根本原因还是要解决一下的,是否此战设置证书有问题?

0条留言