This article describes how to use “openssl” to create a new private key and generate a certificate signing request (CSR). In this example, say we are going to purchase a wildcard certificate on “intennis.com.au” domain.
Create a private key and CSR:
>openssl req -newkey rsa:2048 -nodes -keyout privatekey.openssl -out domain.csr
Generating a 2048 bit RSA private key
…….+++
……………………………………+++
writing new private key to ‘privatekey.openssl’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) []:AU
State or Province Name (full name) []:NSW
Locality Name (eg, city) []:Sydney
Organization Name (eg, company) []:SportLogic
Organizational Unit Name (eg, section) []:inTennis
Common Name (eg, fully qualified host name) []:*.intennis.com.au
Email Address []:
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
Alternative we can specify the subject information via the -subj switch, e.g.
>openssl req -newkey rsa:2048 -nodes -keyout privatekey.openssl -out domain.csr -subj "/C=AU/ST=NSW/L=Sydney/O=SportLogic/OU=IT/CN=*.intennis.com.au"
Next, submit CSR to complete SSL purchase.
After receiving SSL, we chain the certificates together (note the order is important):
>cat STAR_intennis_com_au.crt SectigoRSADomainValidationSecureServerCA.crt USERTrustRSAAddTrustCA.crt AddTrustExternalCARoot.crt > STAR_intennis_com_au.chained.crt
Now we can use both private key (privatekey.openssl) and chained certificates in Nginx. Both files need to be placed in the Nginx SSL directory.
Here is an example of a server conf file utilising the certificate:
... ssl_certificate conf.d/ssl/intennis.com.au/STAR_intennis_com_au.chained.crt; ssl_certificate_key conf.d/ssl/intennis.com.au/privatekey.openssl; ...