How To Generate A San (Subject Alternative Names) SSL CSR With Openssl
How To Generate A San (Subject Alternative Names) SSL CSR With Openssl
T here is a cool SSLv3 protocol extension that’s called SAN (Subject Alternative Names). With
this extension you can create a single SSL X509 certificate that is valid for several domain
names, instead of a classic certificate that’s valid for one domain name only.
You can ofcourse create this kind of certificate with OpenSSL. We are now going to see how to do
that. Fist you have to create a file called openssl.cnf and put it for example into a temporary dir.
The file should begin with:
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
[req_distinguished_name]
countryName = Country Name (2 letter code)
countryName_default = IT
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Italy
localityName = Locality Name (eg, city)
localityName_default = Rome
organizationName = Organization name
organizationName_default = My company name Srl
organizationalUnitName = Organizational Unit Name (eg, section)
organizationalUnitName_default = System Techies
commonName = Common Name (eg, YOUR name)
commonName_max = 64
emailAddress = Email Address
emailAddress_max = 40
The informations above are used by the “openssl req” command to ask you data to generate
your certificate request. Then, add this block of informations into the openssl.cnf file:
[v3_req]
keyUsage = nonRepudiation, digitalSignature, keyEncipherment,
dataEncipherment
extendedKeyUsage = serverAuth, clientAuth
subjectAltName = @alt_names
Those informations will enable some extra useful things on your certificate request that will
hopefully became valid on your brand new SSLv3 certificate. For example you are requesting your
Certification Authority to release a X509 SSLv3 certificate with server and client authentication
purposes, plus other certificate goodies.
Now the cool part: this is where you are asking your CA to release a certificate with Alternative
Names (certificate valid for several domains). Append this stuff in openssl.cnf:
[alt_names]
DNS.1 = www.myfirstdomain.it
DNS.2 = myfirstdomain.it
DNS.3 = www.myalternativedomain.it
# you could also specify IP addresses like this:
# IP.1 = 192.168.25.254
# IP.2 = 192.168.43.100
OK. You are almost ready to create your CSR, but first you have to generate your private key.
NOTE that many CA are now requesting a private key of 2048 bits or more. Warned: a key of 1024
bits is not recommended!
Perfect. It’s time to create the Certificate Request (PKCS#10) with SSLv3 extensions:
Now, send your new server.csr file to your Certification Authority that will hopefully accept the
request and relase a valid X509 SSLv3 certificate with SAN.