環境 | 版本 | 備註 |
---|---|---|
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