生成自签名证书时指定主题备用名称
Specify Subject Alternative Name when generating a self signed certificate
有没有办法获得带有主题备用名称集的 .crt 和 .key 文件?我正在使用此命令生成的 openssl .crt 和 .key 配置代理
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout proxy.key -out proxy.crt
然后我 cat .key 和 .crt 以获得 .pem 并在客户端使用它。
该证书可以很好地保护 https 连接,但我收到一条警告,指出证书中未设置主题备用名称。在我使用的另一个客户端中,警告实际上是一个终止连接的错误。
此处的解决方案 https://security.stackexchange.com/a/91556 给了我一个 .csr,我将其重命名为我需要的 .crt,当我将其与客户端一起使用时,https 连接因不正确的 ssl 证书而失败。
Is there a way to get a .crt and .key file with the subject alternative name set?
是的,但您不能从命令行执行此操作。您必须使用 CONF 文件。
有关通过 CONF 文件设置 SAN 的信息,请参阅 How do you sign Certificate Signing Request with your Certification Authority and How to create a self-signed certificate with openssl?。两者都在程序中包含 SAN。
根据@vog 的 answer:
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout example.key -out example.crt -subj "/CN=example.com" \
-addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"
(请注意,这仅适用于 OpenSSL >= 1.1.1)。
有没有办法获得带有主题备用名称集的 .crt 和 .key 文件?我正在使用此命令生成的 openssl .crt 和 .key 配置代理
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout proxy.key -out proxy.crt
然后我 cat .key 和 .crt 以获得 .pem 并在客户端使用它。 该证书可以很好地保护 https 连接,但我收到一条警告,指出证书中未设置主题备用名称。在我使用的另一个客户端中,警告实际上是一个终止连接的错误。
此处的解决方案 https://security.stackexchange.com/a/91556 给了我一个 .csr,我将其重命名为我需要的 .crt,当我将其与客户端一起使用时,https 连接因不正确的 ssl 证书而失败。
Is there a way to get a .crt and .key file with the subject alternative name set?
是的,但您不能从命令行执行此操作。您必须使用 CONF 文件。
有关通过 CONF 文件设置 SAN 的信息,请参阅 How do you sign Certificate Signing Request with your Certification Authority and How to create a self-signed certificate with openssl?。两者都在程序中包含 SAN。
根据@vog 的 answer:
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout example.key -out example.crt -subj "/CN=example.com" \
-addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"
(请注意,这仅适用于 OpenSSL >= 1.1.1)。