使用OpenSSL检查证书有效性的步骤如下:
openssl x509 -in certificate.crt -noout -dates
这个命令会显示证书的有效期,包括开始日期和结束日期。
openssl x509 -in certificate.crt -noout -CApath /etc/ssl/certs -CAfile /etc/ssl/certs/ca-certificates.crt -checkend 0
这个命令会检查证书是否在CA证书列表中被吊销。-checkend 0
表示检查证书是否在当前时间点有效。
openssl x509 -in certificate.crt -noout -text | grep "Signature Algorithm"
openssl x509 -in certificate.crt -noout -text | grep "Public Key"
这些命令会显示证书的签名算法和公钥信息,包括密钥长度。
openssl x509 -in certificate.crt -noout -subject
openssl x509 -in certificate.crt -noout -issuer
这些命令会显示证书的主题(Subject)和颁发者(Issuer)信息。
openssl x509 -in certificate.crt -noout -serial
这个命令会显示证书的序列号。
openssl x509 -in certificate.crt -noout -ext
这个命令会显示证书的所有扩展信息,包括基本约束、密钥用法、主题替代名称等。
如果你有一个证书链,可以使用以下命令来检查整个链的完整性:
openssl verify -CAfile ca-certificates.crt certificate.crt
这个命令会验证证书是否由指定的CA签发,并且链中的所有证书都是有效的。
通过这些步骤,你可以全面检查证书的有效性和安全性。