Creating the Key Files and SSL Certificate First off, you’ll need to generate all the files required, to install an SSL certificate. The following describes how to generate and obtain these files. Generate Private Key with Openssl Remember the password you typed when generating the key, you will need this later.
openssl genrsa -des3 -out domain.key 2048Generate a Certificate Signing Request (CSR) Follow all prompts and just skip the last 2 extended questions (challenge password and optional company name).
openssl req -new -sha256 -key domain.key -out domain.csrGet a Free Certificate from StartSSL Head over to https://www.startssl.com/ authenticate if you already have an account or sign-up if none. Validate the domain you are installing the ssl for:






Installing the SSL Certificate and Configuring the nginx Server
Now we need to install the certificate and configure nginx to serve through the correct port. Start by decrypting the private key by using the password you entered earlier.openssl rsa -in domain.key -out /home/user/ssl/ssl-out.keyNote that I arbitrarily chose where I wanted to place the ssl key and certificate, you can place this anywhere you like as long as it can’t be accessed by web traffic or the public. Ensure that the key is protected.
chmod 600 /home/user/ssl/ssl-out.keyFetch the Root CA and Class 1 intermediate Server CA certificates:
wget http://www.startssl.com/certs/ca.pem wget http://www.startssl.com/certs/sub.class1.server.ca.pemCreate a unified certificate from your certificate and the rest of the CA certificates.
cat ssl.crt sub.class1.server.ca.pem ca.pem > /home/user/ssl/ssl-uni.crtOpen the corresponding nginx virtual host configuration and make the necessary edits. Add the following entries in the server module:
server { listen 80; listen 443; ssl on; ssl_certificate /home/user/ssl/ssl-uni.crt; ssl_certificate_key /home/user/ssl/ssl-out.key; server_name your.domain.com; ...You are done! For security’s sake, please make sure that ssl-uni.crt and ssl-out.key are placed outside a folder not accessible by the public (usually outside public_html). ]]>