Curl

在 Tomato USB 上捲曲 - SSL CA 問題

  • July 31, 2012

我安裝了 optware,並且可以使用 curl。我試圖讓它在路由器重新啟動時通知我(通過 pushover)。

curl \
-F "token=<token goes here>" \
-F "user=<user key goes here>" \
-F "message=ASUS Router WAN Up" \
https://api.pushover.net/1/messages

這是使用 Tomato 韌體 1.28.0000 MIPSR2-097 K26 USB Mega-VPN 的華碩 RT-N16 路由器

錯誤消息表明安裝的 CA 存在問題:

url: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
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.

那麼安裝 CA 包的推薦方法是什麼?還是我應該不安全(-k 有效)?

如果您確實閱讀了錯誤消息中的 URL,它將解釋為什麼會發生這種情況以及您的選擇是什麼。總結是你有兩個選擇:

  1. 禁用證書驗證,這意味著 cURL 不會檢查您是否連接到正確的伺服器,並且您可能會受到 MITM 攻擊。在這種情況下這可能沒問題,因此請指定--insecure禁用檢查的選項。
  2. 安裝一組 CA 證書以供 cURL 信任。如果 Tomato 不提供包,您可以從 cURL 網站下載 CA 包(它只是從 Mozilla 集轉換而來的)。儲存在系統上的某個位置,並使用選項cacert.pem將 cURL 指向它。--cacert

引用自:https://serverfault.com/questions/412727