1. Create a configuration file that includes `subjectAltName`. The example file listed as follows:
```
[req]
prompt=no
default_bits=2048
distinguished_name=req_dn
req_extensions=req_ext
[req_dn]
CN=<Common Name>
OU=<Organization Unit>
O=<Organization>
L=<Location>
ST=<State>
C=<Country>
emailAddress=<Email Address>
[req_ext]
subjectAltName = @alt_names
[alt_names]
DNS.1=<first subject alt name>
DNS.2=<second subject alt name>
```
2. Run the following command to generate CSR and private key using the config file.
`openssl req -new -newkey rsa:2048 -config ssl.cnf -keyout cert.key -out cert.csr -nodes`
### See also
1. [[How to create CSR?]]
2. [[OpenSSL Config File]]