简体   繁体   English

如何使用 Openssl 制作自签名 RSA_PSS_RSAE 证书

[英]How to make self-signed RSA_PSS_RSAE certificate using Openssl

I would like to make Certificate like following.我想制作如下证书。 rsassaPss as Signature Algorithm and rsaEncryption as Public Key Algorithm. rsassaPss 作为签名算法,rsaEncryption 作为公钥算法。

Certificate:
    Data:
        Version: 3 (0x2)
        ....
    Signature Algorithm: rsassaPss
         Hash Algorithm: sha1 (default)
         Mask Algorithm: mgf1 with sha1 (default)
         Salt Length: 20 (default)
         Trailer Field: 0xbc (default)
        ....
        Subject: .....
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
            .....

I tried followings, but both result same.我尝试了以下方法,但结果相同。

1 1

openssl genpkey -algorithm RSA-PSS -out test1\ca2.key.pem -pkeyopt rsa_pss_keygen_md:sha1 -pkeyopt rsa_pss_keygen_mgf1_md:sha1 -pkeyopt rsa_pss_keygen_saltlen:20
openssl req -x509 -new -nodes -key test1\ca2.key.pem -days 1024 -out test1\ca2.crt.pem 

2 2

openssl req -new -newkey rsa-pss -pkeyopt rsa_keygen_bits:2048 -sigopt  rsa_mgf1_md:sha256 -passout pass:123456 -sha256
openssl x509 -req -in test3\rootreq.pem -passin pass:123456 -sha256 -days 14600 -extensions v3_cn -signkey test3\rootkey.pem -out test3\rootcert.pem 

Can anyone help me?谁能帮我?

To get what you show, create the keyfile as v1.5 but sign the cert with PSS.要获得您显示的内容,请将密钥文件创建为 v1.5,但使用 PSS 签署证书 For a self-signed cert:对于自签名证书:

# in separate steps either of
openssl genrsa 2048 >keyfile 
openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 >keyfile
# in either case add encryption if desired; your Q is inconsistent about that

# then
openssl req -new -x509 -key keyfile -sigopt rsa_padding_mode:pss -sha1 -sigopt rsa_pss_saltlen:20 -out certfile
# add options for subject, days, extensions, or other config as desired
# for 1.0.0 & 1.0.1 -sha1 was default for hash and can be omitted;
# in all versions MGF1 hash defaults to data hash
# but saltlen defaults to 0xEA -- I'm not sure why -- and must be set

# in one step
openssl req -new -x509 -newkey rsa:2048 -keyout keyfile -sigopt rsa_padding_mode:pss -sha1 -sigopt rsa_pss_saltlen:20 -out certfile

That said, I mostly agree with Matt's comment;也就是说,我基本同意马特的评论; this is not necessarily what you need for a TLS1.3 rsa_pss_rsae signature, if that's your actual goal.如果这是您的实际目标,这不一定是 TLS1.3 rsa_pss_rsae 签名所需要的。 First, the signature on a self-signed, root or other anchor cert doesn't contribute to security at all and usually isn't even checked;首先,自签名、root 或其他锚定证书上的签名根本不利于安全,通常甚至不会被检查; RFC8446 4.2.3 explicitly allows that signature to not satisfy sigalgs. RFC8446 4.2.3 明确允许该签名不满足 sigalgs。 (Although I think this is a mistake; given the rest of the spec, it would make more sense to excuse it from sigalgs or sigalgs_cert whichever applies.) (虽然我认为这是一个错误;考虑到规范的其余部分,从 sigalgs或 sigalgs_cert 中原谅它会更有意义,以适用者为准。)

Second, if this were a signature that matters -- on a cert issued by a (distinct) CA, which OpenSSL can also do if you want, but differently -- then using SHA-1 would be very bad.其次,如果这一个重要的签名——在由(不同的)CA 颁发的证书上,如果你愿意,OpenSSL 也可以这样做,但不同的是——那么使用 SHA-1 将非常糟糕。 RFC8446 allows cert signatures to use SHA-1 only as a last resort -- for any publickey algorithm (RSAv1.5, RSA-PSS, ECDSA, EdDSA) -- and some implementations do not trust certs using them ever following 'shattered' and now 'shambles' (google, or look at crypto.SX and security.SX for details). RFC8446允许证书签名使用SHA-1只能作为最后的手段-对任何公钥算法(RSAv1.5,RSA-PSS,ECDSA,EdDSA) -和一些实现使用它们不信任证书永远以下做“粉碎”和现在“混乱”(谷歌,或查看 crypto.SX 和 security.SX 了解详细信息)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM