PHP 使用curl访问https请求报错

2016-02-07 15:57:00
hainuo
原创 2201
摘要:php中使用curl请求https网址时,报错SSL certificate problem: self signed certificate in certificate chain code 60
php中使用curl请求https网址时,源代码如下```$ch = curl_init();// Set urlcurl_setopt($ch, CURLOPT_URL, $url);// Set methodcurl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');// Set optionscurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// Send the request & save response to $resp$resp = curl_exec($ch);```报错`SSL certificate problem: self signed certificate in certificate chain code 60`这个问题该如何解决呢?很简单,屏蔽掉ssl链接验证。```curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);```具体原理可以参见[Using cURL in PHP to access HTTPS (SSL/TLS) protected sites](http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/ "Using cURL in PHP to access HTTPS (SSL/TLS) protected sites")
发表评论
拾 减 零 =
评论通过审核后显示。