Follow the simple steps to create a SSL certificate:
Set up:
It is advisable to have apache already installed on your virtual server. However , if not then it can be downloaded with the help of the following command:
sudo apt-get install apache2
Activation of SSL module:
One needs to perform the following steps:
Enable SSL on the droplet. The command is:
sudo a2enmod ssl
Restart the apache. The command is:
sudo service apache2 restart
Creation of a new directory:
A new directory needs to be created to store server key and certificate. The command is : sudo mkdir /etc/apache2/ssl
Creation of self-signed SSL certificate:
A self-signed certificate can be created by defining the period of the SSL certificate after which it will expire. The SSL certificates have a maximum validity of a year. The command is :
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt.
With the help of the above mentioned command, the newly created SSL certificate and server key will be placed within a new directory.
Installation of the certificate:
The next step after the creation of the SSL certificate is to install the virtual hosts to display the certificate. To open the SSL file, following command is used:
nano /etc/apache2/sites-available/default-ssl
Add a line about your server name underneath the server admin email:
ServerName example.com:443
Now , the next step is to interchange example.com with your DNS approved domain name or server IP address :
SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key
Save and exit the file
Activation of the new virtual host:
Before the website gets activated on the 443 port , enable the virtual host: sudo a2ensite default-ssl
Now restart your apache server to upload all the changes. In the browser type your address and you will find the updated SSL certificate.