Jump to content

SSL Certificate Test

From LemonWiki共筆

SSL 憑證測試

SSL 憑證測試的線上服務

定期檢查 SSL 憑證的線上服務

SSL 憑證測試線上掃描服務

SSL 憑證測試掃描工具



在自己電腦 SSL 憑證測試

以下以 example.com 為例,檢查網站憑證、伺服器提供的憑證鏈,以及實際驗證結果。

1. 查看伺服器提供的憑證鏈

openssl s_client \
  -connect example.com:443 \
  -servername example.com \
  -showcerts \
  </dev/null

查看 Certificate chain:

  • s::憑證主體。
  • i::憑證簽發者。
  • 每張憑證的簽發者,應能銜接下一張憑證的主體。
  • 根憑證通常不需要由伺服器傳送。

列出憑證鏈不代表已通過信任驗證。

2. 查看憑證期限、序號與指紋

openssl s_client \
  -connect example.com:443 \
  -servername example.com \
  </dev/null 2>/dev/null |
openssl x509 -noout \
  -subject -issuer -serial -dates -fingerprint -sha256

重點欄位:

欄位檢查用途
subject憑證主體
issuer簽發者
notBefore/notAfter有效期間
serial憑證序號
SHA256 Fingerprint比對更新前後是否為同一張憑證

指紋不同,表示網站憑證已更換;指紋相同但鏈不同,可能只是修正了憑證鏈。

3. 驗證憑證信任與網域名稱

openssl s_client \
  -connect example.com:443 \
  -servername example.com \
  -verify_hostname example.com \
  -verify_return_error \
  </dev/null

成功時應看到:

Verification: OK
Verified peername: example.com
Verify return code: 0 (ok)

這表示通過本機 OpenSSL 使用的信任庫與網域驗證,不等於所有用戶端皆能通過,也不代表已完成撤銷狀態檢查。

4. 使用 curl 驗證 HTTPS 請求

curl -sS -o /dev/null \
  -w "HTTP=%{http_code} ssl_verify=%{ssl_verify_result}\n" \
  https://example.com/

例如:

HTTP=200 ssl_verify=0
  • HTTP=200:首頁請求成功。
  • ssl_verify=0:憑證驗證成功。

其他 HTTP 狀態碼不一定代表 SSL 有問題,例如 301、302 表示轉址。若要跟隨轉址,可加入 -L:

curl -sS -L -o /dev/null \
  -w "URL=%{url_effective} HTTP=%{http_code} ssl_verify=%{ssl_verify_result}\n" \
  https://example.com/

檢測時不要使用 -k 或 --insecure,否則會跳過憑證驗證。

5. 使用 SSL Labs 進行外部檢測

1. 前往 SSL Server Test (Powered by Qualys SSL Labs) (範例:Google.com 檢測結過)

2. 確認:

  1. 選擇重新測試,避免只查看舊快取。
  2. 測試時間晚於憑證更新時間。
  3. 沒有憑證不受信任、過期或網域不符警告。
  4. 展開 Certification Paths,確認能連到受信任根憑證。
  5. 若網站有多個 IP,確認各端點的結果。

顯示 SSL 憑證資訊

免費 SSL 憑證

Further reading



Web site design and development process