环境 | 版本 | 备注 |
---|---|---|
windows | 10 pro | -- |
PHP | 5.4 | -- |
当你执行 PHP CURL 调用 HTTPS URL 时, 可能出现以下错误:php
SSL certificate problem: unable to get local issuer certificatehtml
Windows 下的 PHP CURL 默认配置是不信任任何根证书 "not trust any root certificate"
因此会出现以上错误提示 [Linux 有多是根证书缺失]windows
方案一 : 禁用 HTTPS 证书验证 (强烈不推荐)curl
// 如下必须同时为假 curl_opt($ch, CURL_SSL_VERIFYPEER, FALSE); curl_opt($ch, CURL_SSL_VERIFYHOST, 0);
方案二 : 从新配置CA根证书路径url
1. 下载 http:\\curl.haxx.se\ca\cacert.pem 到 'C:\ca\cacert.pem' 2. 配置 php.ini extension => php_openssl.dll 开启 curl.cainfo = 'C:\ca\cacert.pem' openssl.cafile='C:\ca\cacert.pem' 3. 或者 curl_setopt 设置 CURL_CAINFO 为 'C:\ca\cacert.pem'
参考 :code
StackOverFlow | Zend | CnBlogs | digicerthtm