可以用 openssl x509 来查看 ca.crt(CA 证书)的详细信息。
一、查看证书的完整可读信息(最常用)
openssl x509 -in ca.crt -noout -text
会看到包括:
- 证书版本(Version)
- 序列号(Serial Number)
- 签名算法(Signature Algorithm)
- 颁发者(Issuer)
- 使用者(Subject)
- 有效期(Not Before / Not After)
- 公钥信息
- 扩展字段(Key Usage、Basic Constraints、Subject Key Identifier 等)
判断是否为 CA 证书,重点看:
X509v3 Basic Constraints:
CA:TRUE
二、只看关键信息(简洁版)
openssl x509 -in ca.crt -noout \
-issuer \
-subject \
-dates \
-serial
输出示例:
issuer= /C=CN/O=Example CA/OU=Root CA/CN=Example Root CA
subject= /C=CN/O=Example CA/OU=Root CA/CN=Example Root CA
notBefore=Jan 1 00:00:00 2024 GMT
notAfter=Dec 31 23:59:59 2033 GMT
serial=01A3F5
三、查看指纹(常用于比对)
openssl x509 -in ca.crt -noout -fingerprint -sha256
SHA-1(旧系统可能还在用)
openssl x509 -in ca.crt -noout -fingerprint
四、查看公钥信息
openssl x509 -in ca.crt -noout -pubkey
如果你想进一步分析公钥(如 RSA 位数):
openssl x509 -in ca.crt -noout -pubkey | openssl rsa -pubin -text -noout
五、判断是否为自签名 CA
openssl x509 -in ca.crt -noout -issuer -subject
如果 Issuer == Subject,通常是 自签名根 CA。
六、校验证书格式是否正常
openssl x509 -in ca.crt -noout
无输出、无报错说明格式 OK。