Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subject Alternative Name is not copied to signed certificate

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.

like image 617
4ybaka Avatar asked Nov 29 '15 23:11

4ybaka


People also ask

What is certificate subject alternative name?

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.

How do you add subject alternative name to certificate using OpenSSL?

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.

How many subject alternative names can a certificate have?

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.


1 Answers

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.

like image 178
frasertweedale Avatar answered Oct 09 '22 17:10

frasertweedale