Generate a self-signed SSL certificate - Nginx,CentOS


Following article describes how to generate and install a self-signed SSL certificate for a domain.

Requirements

Self signed SSL

As the name indicates, they are certificates that is signed by the same entity whose identity it certifies. Since self signed SSL certificates are not validated/trusted by any Certificate Authority, its usage in production environment is not reccomended. However its a favourable choice in development environment since self signed SSL certificates are free and can be created/deployed very easily.

How to

  • Login to your server and switch to root by executing sudo su.

  • Create a directory to store SSL certificates

     mkdir /etc/nginx/ssl
     cd /etc/nginx/ssl
    
  • Execute the below command to generate self signed certificate

     root@your-server-$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/self.key -out /etc/nginx/ssl/self.crt
    
  • Enter the required information during the prompt.

     Generating a 2048 bit RSA private key
     ....................................+++
     ..........+++
     writing new private key to '/etc/nginx/ssl/self.key'
     -----
     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) [XX]:  
     State or Province Name (full name) []:
     Locality Name (eg, city) [Default City]:
     Organization Name (eg, company) [Default 
     Company Ltd]:
     Organizational Unit Name (eg, section) []:
     Common Name (eg, your name or your 
     server's hostname) []:
     Email Address []:
    
  • SSL key and certificate will be generated in the location /etc/nginx/ssl.

     root@your-server-$ pwd
     /etc/nginx/ssl
     root@your-server-$ ls
     self.crt  self.key
    

Nginx

  • Edit nginx configuration file

     root@your-server-$ vi /etc/nginx/conf.d/default.conf 
    
  • Edit the following parameters

    listen       443 ssl;
    server_name  yourdomain.com;
    ssl_certificate     /etc/nginx/ssl/self.crt;
    ssl_certificate_key /etc/nginx/ssl/self.key;
    
  • Restart nginx service

    root@your-server-$ service nginx restart
    Stopping nginx:                                              [  OK  ]
    Starting nginx:                                            [  OK  ]
    

Verify that your site is loading with self signed certificate.

https://yourdomain.com

While accessing the site, you will be presented with a warning message. This happens due to the self signed certificate we installed. You can continue to the website by accepting the connection.

Your site is now using a self signed SSL certificate.

Bytehouse offers different types of SSL certificates. For production environments, you can purchase an SSL certificate from your Bytehouse account.

Last update:
2016-07-07 02:31
Author:
Bytehouse Technical Support
Revision:
1.1
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Most popular FAQs RSS

  1. I require an additional IPv4 address. What is Bytehouse's ... (87844 views)
  2. The Most Common Problems When Migrating Websites (66193 views)
  3. How do I create a 301 redirect? (54901 views)
  4. Can I Backup Exchange 2010 with My Online Backup ... (53046 views)
  5. Steps to Add Administrator User for Windows Server (48557 views)

Latest FAQs RSS

  1. Steps to set/customize log rotation from plesk (2016-07-25 07:15)
  2. Generate a self-signed SSL certificate - Nginx,CentOS (2016-07-07 02:31)
  3. Procedure re-register Volume Shadow Copy Service(VSS) in a Windows ... (2016-07-05 04:18)
  4. Steps to Install Mcrypt in Plesk (2016-07-01 17:11)
  5. How to Retrieve a Plesk Password in Linux and ... (2016-07-01 17:09)

Regular new KB articles

Check back from time to time for new articles, or if you have any suggestions please feel free to recommend

top