我希望配置OpenSSL,以便在运行openssl req -new
以生成新的证书签名请求时,系统提示我输入要包含在CSR中的任何其他主题名称。
我已将此行添加到[req_attributes]
我的部分openssl.cnf
:
subjectAltName = Alternative subject names
这具有理想的效果,现在在生成CSR时提示我输入SAN:
$ openssl req -new -out test.csr -key ./test.key <<<
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [US]:
State or Province Name (full name) [New York]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Example Co]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:test.example.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Alternative subject names []:DNS:alt1.example.com
在上面的示例中,我DNS:alt1.example.com
在提示您输入SAN时输入。
问题在于生成的CSR似乎格式不正确:
$ openssl req -text -in ./test.csr
Certificate Request:
Data:
Version: 0 (0x0)
Subject: C=US, ST=New York, O=The Banes, CN=test.thebanes.org
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
[...]
Exponent: 65537 (0x10001)
Attributes:
X509v3 Subject Alternative Name:unable to print attribute
OpenSSL抱怨它无法打印“使用者备用名称”属性的值。从在线示例(人们将SAN硬编码到他们的openssl.cnf中,而不是像我所希望的那样交互式地提示它们)中,我希望看到的是:
Attributes:
X509v3 Subject Alternative Name:
DNS:alt1.example.com
那么,如何通过交互式提示的SAN生成格式正确的CSR?
openssl
-您将需要一个脚本来处理其配置文件。:( PS一种以非交互方式完成此任务的可靠解决方案在这里:stackoverflow.com/a/9158662/2693875