在Ubuntu上使用OpenSSL驗證證書步驟如下:
安裝OpenSSL
sudo apt update && sudo apt install openssl
驗證證書鏈
cat server.crt intermediate.crt root.crt > fullchain.crt
openssl verify -CAfile root.crt fullchain.crt
若輸出OK
則鏈有效。檢查證書有效期
openssl x509 -in certificate.crt -noout -dates
輸出notBefore
和notAfter
字段確認有效期。
查看證書詳細信息
openssl x509 -in certificate.crt -noout -text
顯示頒發者、主題、簽名算法等信息。
驗證證書簽名
openssl x509 -in certificate.crt -noout -modulus | openssl md5
openssl rsa -in certificate.key -noout -modulus | openssl md5
兩次MD5值一致則簽名有效(需用證書公鑰驗證)。
檢查證書吊銷狀態(OCSP/CRL)
openssl ocsp -issuer issuer.crt -cert certificate.crt -url http://ocsp.example.com
openssl crl -in crl.pem -noout -text
檢查證書序列號是否在吊銷列表中。說明:替換命令中的文件名為實際路徑,確保文件格式正確(如.crt
或.pem
)。