SSL Certificate Test: Difference between revisions
Appearance
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== SSL 憑證測試 == | == SSL 憑證測試 == | ||
== SSL 憑證測試的線上服務 == | |||
<onlyinclude> | <onlyinclude> | ||
定期檢查 SSL 憑證的線上服務 | 定期檢查 SSL 憑證的線上服務 | ||
| Line 21: | Line 22: | ||
</onlyinclude> | </onlyinclude> | ||
== 在自己電腦 SSL 憑證測試 == | |||
以下以 <code>example.com</code> 為例,檢查網站憑證、伺服器提供的憑證鏈,以及實際驗證結果。 | |||
=== 1. 查看伺服器提供的憑證鏈 === | |||
<pre lang="bash"> | |||
openssl s_client \ | |||
-connect example.com:443 \ | |||
-servername example.com \ | |||
-showcerts \ | |||
</dev/null | |||
</pre> | |||
查看 <code>Certificate chain</code>: | |||
* <code>s:</code>:憑證主體。 | |||
* <code>i:</code>:憑證簽發者。 | |||
* 每張憑證的簽發者,應能銜接下一張憑證的主體。 | |||
* 根憑證通常不需要由伺服器傳送。 | |||
'''列出憑證鏈不代表已通過信任驗證。''' | |||
=== 2. 查看憑證期限、序號與指紋 === | |||
<pre lang="bash"> | |||
openssl s_client \ | |||
-connect example.com:443 \ | |||
-servername example.com \ | |||
</dev/null 2>/dev/null | | |||
openssl x509 -noout \ | |||
-subject -issuer -serial -dates -fingerprint -sha256 | |||
</pre> | |||
重點欄位: | |||
<table> | |||
<tr><th>欄位</th><th>檢查用途</th></tr> | |||
<tr><td><code>subject</code></td><td>憑證主體</td></tr> | |||
<tr><td><code>issuer</code></td><td>簽發者</td></tr> | |||
<tr><td><code>notBefore</code>/<code>notAfter</code></td><td>有效期間</td></tr> | |||
<tr><td><code>serial</code></td><td>憑證序號</td></tr> | |||
<tr><td><code>SHA256 Fingerprint</code></td><td>比對更新前後是否為同一張憑證</td></tr> | |||
</table> | |||
指紋不同,表示網站憑證已更換;指紋相同但鏈不同,可能只是修正了憑證鏈。 | |||
=== 3. 驗證憑證信任與網域名稱 === | |||
<pre lang="bash"> | |||
openssl s_client \ | |||
-connect example.com:443 \ | |||
-servername example.com \ | |||
-verify_hostname example.com \ | |||
-verify_return_error \ | |||
</dev/null | |||
</pre> | |||
成功時應看到: | |||
<pre lang="text"> | |||
Verification: OK | |||
Verified peername: example.com | |||
Verify return code: 0 (ok) | |||
</pre> | |||
這表示通過本機 OpenSSL 使用的信任庫與網域驗證,不等於所有用戶端皆能通過,也不代表已完成撤銷狀態檢查。 | |||
=== 4. 使用 curl 驗證 HTTPS 請求 === | |||
<pre lang="bash"> | |||
curl -sS -o /dev/null \ | |||
-w "HTTP=%{http_code} ssl_verify=%{ssl_verify_result}\n" \ | |||
https://example.com/ | |||
</pre> | |||
例如: | |||
<pre lang="text"> | |||
HTTP=200 ssl_verify=0 | |||
</pre> | |||
* <code>HTTP=200</code>:首頁請求成功。 | |||
* <code>ssl_verify=0</code>:憑證驗證成功。 | |||
其他 HTTP 狀態碼不一定代表 SSL 有問題,例如 <code>301</code>、<code>302</code> 表示轉址。若要跟隨轉址,可加入 <code>-L</code>: | |||
<pre lang="bash"> | |||
curl -sS -L -o /dev/null \ | |||
-w "URL=%{url_effective} HTTP=%{http_code} ssl_verify=%{ssl_verify_result}\n" \ | |||
https://example.com/ | |||
</pre> | |||
檢測時不要使用 <code>-k</code> 或 <code>--insecure</code>,否則會跳過憑證驗證。 | |||
=== 5. 使用 SSL Labs 進行外部檢測 === | |||
1. 前往 [https://www.ssllabs.com/ssltest/ SSL Server Test (Powered by Qualys SSL Labs)] (範例:[https://www.ssllabs.com/ssltest/analyze.html?d=www.google.com Google.com 檢測結過]) | |||
2. 確認: | |||
# 選擇重新測試,避免只查看舊快取。 | |||
# 測試時間晚於憑證更新時間。 | |||
# 沒有憑證不受信任、過期或網域不符警告。 | |||
# 展開 <code>Certification Paths</code>,確認能連到受信任根憑證。 | |||
# 若網站有多個 IP,確認各端點的結果。 | |||
== 顯示 SSL 憑證資訊 == | == 顯示 SSL 憑證資訊 == | ||
| Line 32: | Line 140: | ||
* [https://cipherli.st/ Cipherli.st - Strong Ciphers for Apache, nginx and Lighttpd] | * [https://cipherli.st/ Cipherli.st - Strong Ciphers for Apache, nginx and Lighttpd] | ||
* [https://crashtest-security.com/configure-trusted-certificates/ How to Configure Trusted Certificates | Crashtest Security] {{access | date=2022-05-11}} | * [https://crashtest-security.com/configure-trusted-certificates/ How to Configure Trusted Certificates | Crashtest Security] {{access | date=2022-05-11}} | ||
* [[Glossary of information security]] | |||
| Line 38: | Line 147: | ||
[[Category:Web Dev]] [[Category:Tool]] [[Category:Security]] | [[Category: Web Dev]] | ||
[[Category: Tool]] | |||
[[Category: Security]] | |||
[[Category: Revised with LLMs]] | |||
Latest revision as of 11:40, 3 November 2026
SSL 憑證測試[edit]
SSL 憑證測試的線上服務[edit]
定期檢查 SSL 憑證的線上服務
Secure Certificate Monitoring - LetsMonitor.org [Last visited: 2023-02-17]
SSL 憑證測試線上掃描服務
SSL Server Test (Powered by Qualys SSL Labs): Example report of SSL Report: certbot.eff.org [Last visited: 2022-05-11]
- SSL Checker - SSL Certificate Verify: Example report of SSL Checker - SSL Certificate Verify [Last visited: 2017-08-29]
- OpenSSL Command Line Utilities [Last visited: 2017-02-21]
- Testing for Weak SSL/TLS Ciphers, Insufficient Transport Layer Protection (OTG-CRYPST-001) - OWASP [Last visited: 2017-09-04]
- RapydBlok INSPECT - Audit SSL|TLS Security 報告看起來跟 drwetter/testssl.sh: Testing TLS/SSL encryption anywhere on any port 提供的一樣 [Last visited: 2021-09-11]
SSL 憑證測試掃描工具
- drwetter/testssl.sh: Testing TLS/SSL encryption anywhere on any port License: GNU General Public License v2.0
在自己電腦 SSL 憑證測試[edit]
以下以 example.com 為例,檢查網站憑證、伺服器提供的憑證鏈,以及實際驗證結果。
1. 查看伺服器提供的憑證鏈[edit]
openssl s_client \
-connect example.com:443 \
-servername example.com \
-showcerts \
</dev/null
查看 Certificate chain:
s::憑證主體。i::憑證簽發者。- 每張憑證的簽發者,應能銜接下一張憑證的主體。
- 根憑證通常不需要由伺服器傳送。
列出憑證鏈不代表已通過信任驗證。
2. 查看憑證期限、序號與指紋[edit]
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. 驗證憑證信任與網域名稱[edit]
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 請求[edit]
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 進行外部檢測[edit]
1. 前往 SSL Server Test (Powered by Qualys SSL Labs) (範例:Google.com 檢測結過)
2. 確認:
- 選擇重新測試,避免只查看舊快取。
- 測試時間晚於憑證更新時間。
- 沒有憑證不受信任、過期或網域不符警告。
- 展開
Certification Paths,確認能連到受信任根憑證。 - 若網站有多個 IP,確認各端點的結果。
顯示 SSL 憑證資訊[edit]
- 設定讓 Google Chrome 可直接顯示 SSL 憑證資訊教學 for Chrome
v. 30 [Last visited: 2017-08-06]
免費 SSL 憑證[edit]
Further reading[edit]
- Generate Mozilla Security Recommended Web Server Configuration Files [Last visited: 2019-03-07]
- Cipherli.st - Strong Ciphers for Apache, nginx and Lighttpd
- How to Configure Trusted Certificates | Crashtest Security [Last visited: 2022-05-11]
- Glossary of information security
Web site design and development process
- Information gathering: Research surveys
- Planning: Before you start to build a website, Content development strategy | Register domain name, Choose web hosting | Information architecture | Data model: Data type, Data flow | Documentation: Request For Proposal | Licensing
- Design: CSS tools, Free fonts, Free photos, Emoji & icons
- Testing & delivery: Usability test, check browser compatibility | Web testing | Speed up websites: Web Ping, Software acceptance test plan | Promote your web
- Maintenance: Site backup & restore test, Software update (OS patch or CMS security update)
- Need help? Community, I need inspiration, Web design glossary