对于本地证书,您可以使用以下命令查看主题和直接颁发者:
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
但这并不表明证书是否包含任何中间证书或完整的信任链。如果您的系统无法验证链,您列出的验证命令将失败(例如:您缺少中间证书或根不受信任),显示如下错误消息:
0 深度查找时出现错误 20:无法获取本地颁发者证书
如果要验证文件中的每个条目,可以使用此脚本显示本地证书的信任链:
~ % 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