【问题标题】:How do I check if my SSL Certificate is SHA1 or SHA2 on the commandline如何在命令行上检查我的 SSL 证书是 SHA1 还是 SHA2
【发布时间】:2014-12-15 20:58:15
【问题描述】:

如何从命令行检查我的 SSL 证书使用的是 SHA1 还是 SHA2?

是的,我这类似于this,但我需要一个 cli 工具,我想了解它是如何完成的。

【问题讨论】:

    标签: ssl openssl sha1 sha sha256


    【解决方案1】:

    在谷歌上搜索了一段时间后,我想出了以下 sn-p (unix):

    openssl s_client -connect <host>:<port> < /dev/null 2>/dev/null | openssl x509 -text -in /dev/stdin | grep "Signature Algorithm"
    

    windows(感谢 Nick Westgate,见下文)

    certutil -dump cacert.pem | find "Algorithm"
    

    【讨论】:

    • 在我使用 .p12 证书的 Windows 上,我使用了:certutil -dump crtname.p12 |找到“Cert Hash”(另外,我的证书有密码,所以在按回车后我也必须输入密码。)
    【解决方案2】:

    我知道这个话题很老了,但我认为

    openssl x509 -in yourcert.crt -text -noout | grep "Signature Algorithm"
    

    将是一个更简单的解决方案。

    【讨论】:

    • 这正是第一个答案最终所做的。证书通常安装在 Web 服务器上并且不存在于文件中,并且 rink.attendant.6 的答案会获取证书并在一行中运行验证检查
    • @ShalomCarmel 但这对像我这样想要仔细检查我们继承的证书并拥有对服务器的 shell 访问权限的管理员很有帮助 :)
    【解决方案3】:

    您没有指定平台,但您可以在 Windows 命令提示符中使用:

    certutil -dump cacert.pem | find "Algorithm"
    

    【讨论】:

    • 包括你的答案,谢谢
    【解决方案4】:

    在 PowerShell 中

    PS C:\> certutil -dump cacert.pem | findstr "Algorithm"
    

    【讨论】:

      猜你喜欢
      • 2014-11-06
      • 2012-01-08
      • 1970-01-01
      • 2017-12-15
      • 2015-02-25
      • 1970-01-01
      • 2017-10-15
      • 2021-02-27
      • 1970-01-01
      相关资源
      最近更新 更多