cbe*_*zan 14 ssl openssl certificate
我有一个保存在本地文件中的证书(例如这个).openssl从命令行使用,如何显示从此证书到根CA的整个链?我试过了:
openssl verify -verbose -purpose sslserver -CApath /etc/ssl/certs InCommonServerCA.txt
Run Code Online (Sandbox Code Playgroud)
得到这个令人困惑的输出,似乎只显示叶证书:
InCommonServerCA.txt: C = US, O = Internet2, OU = InCommon, CN = InCommon Server CA
error 26 at 0 depth lookup:unsupported certificate purpose
OK
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
对于本地证书,您可以使用以下方法查看主题和直接颁发者:
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
Run Code Online (Sandbox Code Playgroud)
但这并不表示证书是否包含任何中间证书或完整的信任链。如果系统无法验证链(例如,您缺少中间证书或根目录不受信任),则列出的verify命令将失败,并显示以下错误消息:
在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
Run Code Online (Sandbox Code Playgroud)
如果要验证链和目的,openssl命令是正确的."确定"表示链验证.该错误表明该证书用于sslserver目的存在问题.看起来您的证书是CA证书,而不是叶证书.
你想要展示什么样的连锁信息?您可以查看subject和issuer字段以显示链接.您在上面使用的验证命令证明了一个证书签署了另一个证书.