我需要像图中这样在证书中添加扩展名,我尝试了很多方法,但我不能。
我在运行:
"#openssl req -new -keyout $nomerepre.key -out $nomerepre.csr -passin pass:$senha -config myconfig.cnf"
"#openssl x509 -req -days 365 -in $nomerepre.csr -CA ca.crt -CAkey ca.key -set_serial 10102014 -out $nomerepre.crt -passin pass:$senha -extfile myconfig.cnf -extensions v3_req"
我的配置文件如下
我的configssl.conf
oid_section = OIDs
[ req ]
default_bits = 2048
prompt = no
encrypt_key = no
default_md = sha1
distinguished_name = dn
req_extensions = v3_req
[ OIDs ]
MyOID=2.16.76.1.3.4
[ dn ]
CN = John Smith
emailAddress = john.smith@quovadisglobal.com
O = QuoVadis Group
C = US
[v3_req]
1.2.3.4.5.6.7.8=ASN1:UTF8String:Something
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
#subjectAltName = @alt_names
[alt_names]
MyOID = 00000000111111111112222222222233333333333444444
2.16.76.1.3.4 = 00000000111111111112222222222233333333333444444
不幸的是这样的结果:
最佳答案
我不明白为什么没有扩展名,如 EG2Oa.jpg 所示。您应该在那里有扩展名 1.2.3.4.5.6.7.8
。 SubjectAltName 已被注释,因此它不应出现在证书中。
我尝试使用 xca如图所示,它使用 OpenSSL 1.0.2d
我用过这个配置
# if it should be a separate extension
2.16.76.1.3.4=ASN1:UTF8String:Some random data
#if it should be a part of subjectAltName
subjectAltName=@subject_alt_section
[subject_alt_section]
otherName=2.16.76.1.3.4;UTF8:Some random data
我得到了这个证书
现在是一些理论。我不知道这个扩展应该放在哪里。如果它是一个单独的扩展,或者它是否应该是 SubjectAltName 的一部分。我不知道扩展名应该是 UTF8String 或 OctetString 还是某种序列。
如果您想要一个单独的扩展,您可以使用 2.16.76.1.3.4=ASN1:UTF8String:Some random data
,正如您已经尝试过的那样。可以找到更多关于任意扩展的信息 here .
根据 the description,此扩展名可以是 subjectAltName 的一部分oid 的。 otherName 的定义可以在 RFC5280 in section 4.2.1.6 中找到.如果是这样,那么这个配置对我有用
subjectAltName=@subject_alt_section
[subject_alt_section]
otherName=2.16.76.1.3.4;UTF8:Some random data
使用上面提到的配置,我得到了如下图所示的证书结构。 ASN1Editor用于显示结构。
关于linux - 将扩展名放入 OpenSSL 的证书中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39417627/