curl: (60) SSL certificate problem: unable to get local issuer certificate 錯誤


今天同事做微信分享時,碰到如下

SSL certificate problem: unable to get local issuer certificate。

的錯誤信息。

此問題的出現是由於沒有配置信任的服務器HTTPS驗證。默認,cURL被設為不信任任何CAs,就是說,它不信任任何服務器驗證。

因此,這就是瀏覽器無法通過HTTPs訪問你服務器的原因。

解決此報錯有2種處理方法

  1.如果你的內容不敏感,一個快捷的方法是使用curl_exec()之前跳過ssl檢查項。

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  2.下載一個ca-bundle.crt ,放到對應的目錄,在php.ini文件中配置下路徑

  https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt

  在php.ini加入 ,重啟web服務器

curl.cainfo="真實路徑/ca-bundle.crt"


注:項目使用的是laravel框架,在window電腦下,我首先查找的是如下鏈接:

http://stackoverflow.com/questions/24611640/curl-60-ssl-certificate-unable-to-get-local-issuer-certificate

解決辦法如下:

證書在 https://curl.haxx.se/docs/caextract.html 鏈接里面。

關於“SSL證書問題:無法獲取本地頒發者證書”錯誤。很明顯,這適用於發送CURL請求的系統(並且沒有服務器接收請求)

1)從https://curl.haxx.se/ca/cacert.pem下載最新的cacert.pem

2)將以下行添加到php.ini(如果這是共享托管,並且您無法訪問php.ini,那么可以在public_html中添加到.user.ini)

curl.cainfo=/path/to/downloaded/cacert.pem

3)默認情況下,FastCGI進程將每隔300秒解析新文件(如果需要,可以通過添加幾個文件來更改頻率,如https://ss88.uk/blog/fast-cgi-and-user-ini -files-the-new-htaccess /)

但是,下載的證書不可用,然后只好用

https://github.com/bagder/ca-bundle/blob/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt

鏈接提供的證書解決了問題。

將下載的證書放在php.ini的當前目錄下的extras/ssl/下面。

然后在php.ini文件中加入

curl.cainfo="真實路徑/ca-bundle.crt"(curl擴展是必須開啟的)


解決參考原文:

Thanks @Mladen Janjetovic,

Your suggestion worked for me in mac with ampps installed.

Copied: http://curl.haxx.se/ca/cacert.pem

To: /Applications/AMPPS/extra/etc/openssl/certs/cacert.pem

And updated php.ini with that path and restarted Apache:

    [curl]
    ; A default value for the CURLOPT_CAINFO option. This is required to be an
    ; absolute path.
    curl.cainfo="/Applications/AMPPS/extra/etc/openssl/certs/cacert.pem"
    openssl.cafile="/Applications/AMPPS/extra/etc/openssl/certs/cacert.pem"

And applied same setting in windows AMPPS installation and it worked perfectly in it too.

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo="C:/Ampps/php/extras/ssl/cacert.pem"
openssl.cafile="C:/Ampps/php/extras/ssl/cacert.pem"

Same for wamp.

    [curl]
    ; A default value for the CURLOPT_CAINFO option. This is required to be an
    ; absolute path.
    curl.cainfo="C:/wamp/bin/php/php5.6.16/extras/ssl/cacert.pem"

 




原文:https://blog.csdn.net/sanbingyutuoniao123/article/details/71124655


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM