OpenSSL:如何创建主题 DN 为空的证书?

yon*_*ran 17 openssl x509

是否可以使用仅在主题备用名称属性/扩展名中的标识信息创建 PKCS#10 证书请求/X.509 证书?根据X.509 4.1.2.6 Subject,只要 subjectAltName 是关键的,主题不是 CA 的证书的主题可以为空。

但是当我使用这个配置文件和一个空的 distinct_name 部分时:

# request.config
[ req ]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no

[ req_distinguished_name ]

[ v3_req ]
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName=critical,email:certtest@example.com
Run Code Online (Sandbox Code Playgroud)

和命令

openssl genrsa 1024 > key.pem
openssl req -new -key key.pem -out req.pem -config request.config
Run Code Online (Sandbox Code Playgroud)

OpenSSL 抱怨:

error, no objects specified in config file
problems making Certificate Request
Run Code Online (Sandbox Code Playgroud)

小智 14

这对我有用:

test-no-cn.cnf 文件

[req] 
default_bits       = 4096
encrypt_key        = no
default_md         = sha256
distinguished_name = req_distinguished_name
req_extensions = v3_req

[ req_distinguished_name ]

[ v3_req ]
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName=critical,email:certtest@example.com,URI:http://example.com/,IP:192.168.7.1,dirName:dir_sect

[dir_sect]
C=DK
O=My Example Organization
OU=My Example Unit
CN=My Example Name
Run Code Online (Sandbox Code Playgroud)

生成 CSR

openssl req -new -newkey rsa:4096 -nodes -config test-no-cn.cnf -subj "/" -outform pem -out test-no-cn.csr -keyout test-no-cn.key
Run Code Online (Sandbox Code Playgroud)

签署企业社会责任

openssl x509 -req -days 365 -in test-no-cn.csr -signkey test-no-cn.key -out test-no-cn.crt -outform der -extensions v3_req -extfile test-no-cn.cnf
Run Code Online (Sandbox Code Playgroud)

查看生成的证书

openssl x509 -inform der -in test-no-cn.crt -noout -text
Run Code Online (Sandbox Code Playgroud)


Ora*_*son 8

我也遇到了这个“没有指定对象”的错误。它为各个字段显示这样的提示:

US []:

我只是按 Enter 键,因为我已经在 .cnf 文件中设置了这些值。事实证明我需要再次输入所有值,然后它起作用了。

  • 哦,只有当`prompt = yes [or blank]` 时。如果`prompt = no` 那么`C = US` 表示“US”是默认值。 (5认同)
  • 这是因为配置文件实际上并不包含默认值。`C = US` 表示 C 的“提示”是“US”,而不是默认值。相反,该文件应包含“C = Country”和“C_default = US”。 (3认同)