[英]SSL/TLS operations failing PHP5.6 - curl-ca-bundle.crt & cacert.pem
這已經讓我發瘋了幾個星期了。
我通常在 CentOS 7 機器上進行開發,但最近我開始在 Windows 10 上使用 Xampp,並使用 CentOS 機器向客戶端測試提交代碼。
在 linux 機器上一切正常,但在 Windows 上,任何 SSL/TLS 調用都失敗了,據我所知,這是由於默認情況下驗證對等證書和主機名的 PHP5.6 新功能 - http://php。凈/手冊/en/migration56.openssl.php
我已經在網上和 SO 上閱讀了幾乎所有的操作指南,據我所知,我已經嘗試了所有方法,但一無所獲。
請問有人可以幫忙嗎?!
擴展extension=php_openssl.dll
在php.ini文件中激活,所以是extension=php_curl.dll
。
我還下載了證書文件並將以下內容添加到我的 php.ini 中。
curl.cainfo = "C:\xampp\php\certs\curl-ca-bundle.crt"
curl.capath = "C:\xampp\php\certs\"
openssl.cafile= "C:\xampp\php\certs\curl-ca-bundle.crt"
openssl.capath= "C:\xampp\php\certs\"
我得到的錯誤是:
對於使用 TLS 的 SMTP 調用:
PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in W:\libraries\Zend\Mail\Protocol\Smtp.php on line 206
對於卷曲調用:
API call to messages/send failed: error setting certificate verify locations: CAfile: C:\xampp\php\certs\cacert.pem CApath: none
C:\\xampp\\php\\certs\\
目錄的內容是:
ca-bundle.trust.crt
cacert.pem
curl-ca-bundle.crt
我已經重新啟動了 Apache,甚至嘗試在命令行中使用 curl.exe 作為獨立程序,它在請求 HTTPS 域時工作正常(不確定這是否相關,但我還是嘗試了!)
我還嘗試將以下內容添加到 php.ini(並重新啟動 Apache),但沒有效果。
openssl.verify_peer= false
openssl.verify_peer_name = false
有任何想法嗎?
錯誤消息error setting certificate verify locations
來自 libcurl 本身,意味着它無法找到或打開指定的 CAFile。
在 Windows 上,我認為如果您更改路徑,它會起作用:
curl.cainfo = "C:\xampp\php\certs\curl-ca-bundle.crt"
到
curl.cainfo = "C:/xampp/php/certs/curl-ca-bundle.crt"
OpenSSL 可能也是如此,但我還沒有測試確認。
原來這是一個權限問題,證書文件沒有被讀取 - 將C:/xampp/php/certs/
文件夾移動到另一個位置(例如在我的用戶目錄中)解決了這個問題:)
從godaddy更新證書后出現此錯誤。 我在從客戶端站點發送請求時使用 curl_init 錯誤:0200100D:system library:fopen:Permission denied
任何幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.