Max*_*y-B 13 ssl certificate openssl ssl-certificate
我希望配置 OpenSSL,以便在运行openssl req -new
以生成新的证书签名请求时,系统会提示我将任何备用主题名称包含在 CSR 中。
我已将此行添加到[req_attributes]
我的部分openssl.cnf
:
subjectAltName = Alternative subject names
Run Code Online (Sandbox Code Playgroud)
这具有预期的效果,现在在生成 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
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,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
Run Code Online (Sandbox Code Playgroud)
OpenSSL 抱怨它无法打印主题备用名称属性的值。从在线示例中(人们将 SAN 硬编码到他们的 openssl.cnf 中,而不是按照我的意愿以交互方式提示它们),我希望看到这一点:
Attributes:
X509v3 Subject Alternative Name:
DNS:alt1.example.com
Run Code Online (Sandbox Code Playgroud)
那么,如何使用交互式提示的 SAN 生成格式良好的 CSR?
小智 4
我自己也曾与这个小金块作过斗争……真是个皮塔饼!
我的解决方案:我将所有 openssl.cnf 文件移至模板工具包文件中,只留下 sans 部分作为替换部分,然后在其周围包装一个 perl 脚本。
Perl 脚本提示输入 SAN 条目,然后将它们插入到模板中,将模板保存到临时文件中,然后使用指向临时文件的 -config 选项调用 openssl req。生成 CSR 后丢弃临时文件。
您可能还想查看: http://www.openssl.org/docs/apps/config.html
还有其他人在执行之前覆盖 $ENV 并将对 openssl req 的调用包装在 perl 或 shell 中,并以稍微更有效的方式完成相同的事情: http: //blog.loftninjas.org/2008/11/11/配置 ssl-requests-with-subjectaltname-with-openssl/
归档时间: |
|
查看次数: |
10378 次 |
最近记录: |