我有一个保存在本地文件中的证书(例如 this one)。从命令行使用 openssl
,如何显示从该证书到根 CA 的整个链?我试过:
openssl verify -verbose -purpose sslserver -CApath /etc/ssl/certs InCommonServerCA.txt
得到了这个令人困惑的输出,似乎只显示了叶证书:
InCommonServerCA.txt: C = US, O = Internet2, OU = InCommon, CN = InCommon Server CA
error 26 at 0 depth lookup:unsupported certificate purpose
OK
有什么想法吗?
最佳答案
对于本地证书,您可以使用以下方式查看主题和直接颁发者:
openssl x509 -noout -subject -issuer -in test.crt
subject= /C=US/ST=Utah/L=SLC/O=My Organization/CN=my.server.com
issuer= /C=BE/O=GlobalSign nv-sa/CN=GlobalSign Organization Validation CA - SHA256 - G2
但这并不表示证书是否包含任何中间证书或完整的信任链。如果您的系统无法验证链(例如:您缺少中间证书或根不受信任),您列出的验证命令将失败,显示如下错误消息:
error 20 at 0 depth lookup:unable to get local issuer certificate
如果要验证文件中的每个条目,可以使用此脚本来 show the chain of trust for a local certificate :
~ % ssl_chain.sh google.crt
0: subject= /C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
issuer= /C=US/O=Google Inc/CN=Google Internet Authority G2
1: subject= /C=US/O=Google Inc/CN=Google Internet Authority G2
issuer= /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
2: subject= /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
issuer= /C=US/O=Equifax/OU=Equifax Secure Certificate Authority
google.crt: OK
关于ssl - 显示本地证书文件的整个证书链,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18733383/