generating self-signed CSR/CA Certificate see: Certificate Authority (CA) - Creating Your Own CA & Self-Sign Certificates > 1

Subject Alternative Name (SAN)

the domain name must be defined in the Subject Alternative Name (SAN) section (i.e. extension) of the certificate.

when creating a self-signed certificate, we need to provide a configuration file to OpenSSL and define the SAN in that configuration file. Our command becomes:
openssl req -config san.conf …

example san.conf template

Generate a Self-Signed Certificate

create a 2048-bit private key (private.key) and a self-signed certificate (signed.crt)
openssl req -config san.conf -newkey rsa:2048 -nodes -keyout private.key -x509 -days 365 -out signed.crt

  • -x509 option tells req to create a self-signed certificate
  • -days 365 option specifies that the certificate will be valid for 365 days

Generate a Self-Signed Certificate from an Existing Private Key

create a self-signed certificate (domain.crt) from an existing private key (domain.key)
openssl req -config san.conf -key domain.key -new -x509 -days 365 -out domain.crt

Generate a Self-Signed Certificate from an Existing Private Key and CSR

create a self-signed certificate (domain.crt) from an existing private key (domain.key) and (domain.csr)
openssl x509 -config san.conf -signkey domain.key -in domain.csr -req -days 365 -out domain.crt