ssl - 显示本地证书文件的整个证书链

标签 ssl openssl certificate

我有一个保存在本地文件中的证书(例如 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/

相关文章:

ssl - Twitter + Camel 使用 HTTPS/SSL

php - 为什么在 220 2.0.0 Start TLS 之后不显示任何内容?

python 3 smtplib 异常 : 'SSL: WRONG_VERSION_NUMBER' logging in to outlook

java - 丢失 JRE 7 安全警报和警告

ios - IBM AppCenter 6.2.0 + iOS 上的 SSL - 连接到服务器时永远显示加载 View (无响应失败/成功/超时))

PHP SoapClient SSL 连接超时错误

ios - 如何以有效的方式在 iOS 项目中包含 OpenSSL

encryption - OpenSSL,使用私钥解密

c# - SSLStream 示例 - 如何获得有效的证书?

android - 对于使用 Unity 制作的游戏,无法将更新后的 APK 上传到 Google