【问题标题】:Difference between these two OpenSSL generation methods这两种 OpenSSL 生成方法的区别
【发布时间】:2011-12-10 00:49:35
【问题描述】:

我正在尝试创建自己的根 CA。

这是生成自签名根密钥/证书的一种方法。

openssl req -x509 -nodes -newkey rsa:2048 -subj /CN=$1/countryName=UK/stateOrProvinceName=UK/organizationName=Me -keyout $1.key.pem -out $1.cert.pem

还有一个。

openssl genrsa -des3 -out $1.key.pem 2048
openssl req -new -subj /CN=$1/countryName=UK/stateOrProvinceName=UK/organizationName=Me -key $1.key.pem -out $1.csr
openssl x509 -req -days 36500 -in $1.csr -signkey $1.key.pem -out $1.crt.pem

如果我使用第一个证书创建客户端和服务器连接(使用 QSslSocket),则连接正常。问题是证书上的日期是 1975 年,我不能用它来签署任何其他人。

我构造了第二种方法来生成具有无效日期的根证书,但是 ssl 套接字连接失败并出现“未知”错误并且没有其他线索。我检查了客户端和服务器上都在使用正确的证书

我做错了什么?谢谢。

【问题讨论】:

    标签: qt sockets ssl openssl x509


    【解决方案1】:

    如果你使用-days 36500,那么时间会回到 1975 年:

        Validity
            Not Before: Oct 18 11:57:31 2011 GMT
            Not After : Aug 18 05:29:15 1975 GMT
    

    使用较小的 -days 值。例如:

    openssl req -x509 -days 3000 -nodes -newkey rsa:2048 -subj /CN=xx/countryName=UK/stateOrProvinceName=UK/organizationName=Me -keyout xx.key.pem -text -out xx.cert.pem
    

    那么你应该得到有效日期:

        Validity
            Not Before: Oct 18 12:01:17 2011 GMT
            Not After : Jan  4 12:01:17 2020 GMT
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-08
    • 2019-03-31
    • 2020-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多