linux - 将扩展名放入 OpenSSL 的证书中

标签 linux ssl certificate ssl-certificate

我需要像图中这样在证书中添加扩展名,我尝试了很多方法,但我不能。

OK Image

我在运行:

"#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

不幸的是这样的结果:

Error image

最佳答案

我不明白为什么没有扩展名,如 EG2Oa.jpg 所示。您应该在那里有扩展名 1.2.3.4.5.6.7.8。 SubjectAltName 已被注释,因此它不应出现在证书中。

我尝试使用 xca如图所示,它使用 OpenSSL 1.0.2d xca about

我用过这个配置

# 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

我得到了这个证书

generated certificate


现在是一些理论。我不知道这个扩展应该放在哪里。如果它是一个单独的扩展,或者它是否应该是 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用于显示结构。

Asn1 structure of the certificate

关于linux - 将扩展名放入 OpenSSL 的证书中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39417627/

相关文章:

rest - 如何从 Bluemix 通过 SSL 调用外部 REST 服务

ssl - MSMQ 无法通过 HTTPS 发送

certificate - 如何使用 keytool 将证书创建到 PKCS12 keystore 中?

java - 使用 DEROctetString 与纯扩展

c - Linux 模块 : performance counter does not work

database - 在 Oracle Linux 6 中配置 Oracle 11g 数据库

linux - 错误 ./vpdetection :/gpfs/apps/x86_64-rhel5/matlab/R2012a/sys/os/glnxa64/libstdc++. so.6:找不到版本 `GLIBCXX_3.4.14'

linux - 如何使用终端在 Linux 中创建仅包含 .txt 扩展名的文件的 zip 存档

java - Apache FTPS 客户端 storeFile 从 Unix/Linux/Max 问题到 Windows FTPS 服务器

authentication - 使用USB token 或智能卡上的数字签名证书从浏览器进行用户身份验证