Ubuntu 16.04 curl: Server Certificate Verification Failed.

今天看到有使用者留言說,我的股票精算師的指數不會更新了,小蛙檢查了一下,哇賽~從 5/16 開始就不會動了,立馬看看出了什麼問題。

一開始以為是之前搬伺服器的時候,Cloudflare 設定的問題,查了一段時間後發現連搜尋股票代號的功能都失效了,進資料庫看一下股票代號表,發現空白一片,此時大概知道問題出在哪裡。

把 crontab 裡更新股票代碼跟指數的 API 叫出來看一下發現「curl: server certificate verification failed.」這個錯誤,仔細看一下錯誤訊息裡面其實就有解決方法了,不過小蛙還是記錄一下備查。

curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.

有看到亮點了嗎?原本是 curl https://wxxxxxxx 改成 curl -k https://wxxxxxx 就可以忽略掉這個問題,但是同時也要注意存取目的的安全性喔!


發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *