如何用openssl命令创建csr文件时添加attributes?
openssl req -ecdsa-with-SHA1 -new -key a.pem -subj "/DC=a" -out a.csr
如下:
无attributes

有attributes

要在使用 openssl 命令创建 CSR 文件时添加 attributes,你可以向命令行选项中添加 -reqexts 和 -config 参数,并在 OpenSSL 配置文件中指定自定义的 attributes 配置。具体步骤如下:
- 创建一个 OpenSSL 配置文件(例如 openssl.cnf),并在文件中添加如下内容:
[req_attributes]
challengePassword = A challenge password
unstructuredName = An optional company name
这里的 challengePassword 和 unstructuredName 是 examples,您可以根据需要指定其他自定义属性。 - 执行以下 openssl 命令,向其添加 -config 和 -reqexts 选项:
openssl req -ecdsa-with-SHA1 -new -key a.pem -subj "/DC=a" -out a.csr -config openssl.cnf -reqexts req_attributes
这将使用指定的 OpenSSL 配置文件和 req_attributes 扩展来创建 CSR 文件,并在其中包含你指定的自定义 attributes。
以上是使用 OpenSSL 命令添加 attributes 的步骤。需要注意的是,这只是其中的一种方法,具体实现方式可能因 OpenSSL 版本和配置而有所不同。
不知道你这个问题是否已经解决, 如果还没有解决的话:
如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^