关于PHP cURL:SSL certificate error: unable to get local issuer certificate 问题

Window下PHP调用curl接口访问https网址时报错:

<blockquote>

SSL certificate error: unable to get local issuer certificate


</blockquote>

尝试关闭SSL_VERIFY验证,也可以解决问题,但是强烈不建议用该方法:

<blockquote>

curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);


</blockquote>

最好的解决办法是添加certificate认证文件并修改PHP.ini配置

认证文件下载地址:https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt|41708e09ac01ea94da76a321c7c28c6611|

php.ini 修改如下:

<blockquote>

curl.cainfo="C:/wamp/ca-bundle.crt"
openssl.cafile="C:/wamp/ca-bundle.crt"


</blockquote>

问题彻底解决

标签: php, curl, ssl

添加新评论