I use self-signed CA cert to sign other certificates. For some certs I need to specify subject alternative names. I can specify them during request generation (openssl req ...
) and I see them in .csr file. Then I sign it with CA cert using
openssl x509 -req -extensions x509v3_config -days 365 -in ${name}.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out ${name}.crt
and next sections in openssl.cnf file:
[ x509 ]
x509_extensions = x509v3_config
[ x509v3_config ]
copy_extensions = copy
but I see no SAN in .crt file.
I know about solutions with openssl ca ...
command but I have no valid [ca]
section and I don't want to copy/paste it without deep understanding what it does. So I hope that exists another solution with openssl x509 ...
command.
The Subject Alternative Name field lets you specify additional host names (sites, IP addresses, common names, etc.) to be protected by a single SSL Certificate, such as a Multi-Domain (SAN) or Extend Validation Multi-Domain Certificate.
If you want your certificates to support Subject Alternative Names (SANs), you must define the alternative names in a configuration file. OpenSSL does not allow you to pass Subject Alternative Names (SANs) through the command line, so you have to add them to a configuration file first.
Subject Alternative Name (SAN) Certificates Depending on the issuing Certificate Authority, SAN certificates can support 100 or more different FQDNs in one certificate. A SAN certificate includes the standard Subject Name field, which supports a single primary web-based service name.
The copy_extensions
directive is only understood by the openssl ca
command. There is no way to copy extensions from a CSR to the certificate with the openssl x509
command.
Instead, you should specify the exact extensions you want as part of the openssl x509
command, using the same directives you used for openssl req
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With