Introduction to Secure Sockets Layer (SSL Certificate)
SSL stands for Secure Sockets Layer. It is used to secure the connection between internet browsers and Web server or websites by transferring the encrypted data rather than plain text. You can secure the HTTP connections by installing an SSL certificate. There are two types of certificates.
* SSL certificate issued by the Certificate Authority (CA) and,
* Self-Signed SSL certificate.
The main difference between these two types is that for a Self-Signed certificate, no third party is verifying the identity information of the Website and hence it is not trusted by any of the web browsers. So, accessing the website with self-signed SSL will prompt Untrusted Connection and you’ll have to Confirm Security exception manually. This is something users wouldn’t like to do. This is where SSL certificates verified by a CA comes into play. The CA verifies the webste identity information and also provides CA Bundle (for browser compatibility). So these connections are accepted by almost all the browsers.
For installing SSL certificate (both types), we need to generate Private Key and CSR (Certificate signing request).
Check our website hosting packages from just £2.69 (it includes free SSL certificate)
Step 1) Generate Private key on the server
OpenSSL is the open source SSL package that comes along with most of the linux distros. Make sure openssl package is installed. Refer the screenshot.
We are generating private key with openssl command as shown below.
openssl genrsa -des3 -out www.domain.com.key 2048
This will prompt a passphrase as shown in the screenshot.
When you enter the passphrase and hit ‘Enter, the key file will be generated in the present working directory and the file name will be ‘www.domain.com.key’, where domain is name of the domain that you enter when the key is generated.
Step 2) Generate Certificate Signing Request (CSR)
After generating your private key, you need to generate a CSR (Certificate Signing Request). You can easily create that with openssl command.
openssl req -new -key www.domain.com.key -out www.domain.com.csr
Few questions regarding the website identity will be asked and this will be checked by the certificate authority. You can refer the screenshot for this.
CSR will be generated in the present working directory with the file name ‘www.domain.com.csr’. Here is the screenshot of the CSR file.
Step 3) Create SSL Certificate
After generating Private key and CSR, you need to create the SSL certificate. Now is where the difference come into play.
For a CA verified cerificate you need to provide CSR and Private key to the Certificate vendor. They will provide a CA verified certificate file (.crt file) and you can install it. But for a Self-Signed certificate, you need to generate the certificate manually.
Generating Self-Signed certificate
Certificate file will be generated with private key and CSR encoded in it. All the information for in the Private key and CSR will be encoded in the .crt file. Command is given below.
openssl x509 -req -days 365 -in www.domain.com.csr -signkey www.domain.com.key -out www.domain.com.crt
If you refer the screenshot, you can see that the data entered while creating CSR is encoded.
Certificate file will be generated in the present working directory as ‘www.domain.com.crt’, please note that domain.com is my domain name in this example and it should be replaced with the actual domain name. Here is the generated .crt file
To install this certificate for a website, you need to create a new VirtualHost for the domain name because SSL is using a different port and not the common port 80. SSL port is 443. So Apache will be listening to both 80 and 443 for the non-encrypted and encrypted data respectively. Or, you can create a separate conf file, in /etc/httpd/conf.d directory and then ask Apache to refer the said directory with ‘Include’ directive as shown below.
Now, add the below given code either in the VirtualHost or in the separate configuration (eg: ssl.conf) file created in the /etc/httpd/conf.d direcory.
SSLEngine on SSLCertificateFile /path_of_crt_file/www.domain.com.crt SSLCertificateKeyFile /path_of_key_file/www.domain.com.key
This will tell apache to refer the .crt (certificate) file and .key (Private key) file for SSL encrypted connection.
Step 4) Restart Apache
Final step is to restart Apachge service for the changes to take effect.
You can verify the SSL setup by just loading your website with HTTPS, eg: https://domain.com
If your website is loading with https, be sure you have SSL installed for your website 🙂
Of course, if that all looks too much then you can just get us to install your SSL certificate for you if you are using one of our hosting plans. Or you can purchase a low cost SSL certificate and we will do everything for you end to end.