【问题标题】:Verify certificates using OpenSSL使用 OpenSSL 验证证书
【发布时间】:2015-04-14 20:30:54
【问题描述】:

我创建了 2 个名为 cert1.crt 和 cert2.crt 的中间证书,由一个通用 cert0 根签名,我需要使用 verify 命令验证它们。

我输入:

verify -CAfile cert1.crt cert2.crt

我得到的是:

error 20 at 0 depth lookup:unable to get local issuer certificate.

当我用我从证书生成的两个 .pem 文件替换 .crt 文件时出现同样的错误。 我究竟做错了什么?我使用 OpenSSL 工具包,我的操作系统是 Windows 8。

【问题讨论】:

标签: ssl openssl


【解决方案1】:

我不知道你如何创建一个通用的 cert0 根目录。

您可以通过以下步骤做到这一点:

0) 创建 CA 私钥和 rootreq

$ openssl req -nodes -newkey rsa:1024 -sha1 -keyout rootkey.pem -out rootreq.pem

1) 创建 CA 自签名证书

$ openssl x509 -req -in rootreq.pem -sha1 -signkey rootkey.pem -out rootcert.pem

2) 创建客户端私钥和证书

$ openssl req -nodes -newkey rsa:1024 -sha1 -keyout userkey.pem -out userreq.pem

3) 使用客户端 certreq 创建客户端证书 $ openssl x509 -req -in userreq.pem -sha1 -CA rootcert.pem -CAkey rootkey.pem -CAcreateserial -out usercert.pem

4) 验证证书

$ openssl verify -CAfile rootcert.pem usercert.pem

您可以使用不同的输出重复步骤 2) 和 3) 以创建一些客户端证书,并在步骤 4) 进行验证。

【讨论】:

    猜你喜欢
    • 2012-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-21
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    相关资源
    最近更新 更多