Nowadays, an SSL certificate which is usually used for HTTPS connections become pretty important. Even Google starts to give a ranking boost to secure HTTPS/SSL sites. There are several cheap certificates that you can buy like Comodo PositiveSSL. I usually buy cheap certificates from Namecheap.com which provides SSL certificates as low as $4/year. After you buy the certificate, you need to set up your server. Here are the steps to set up an SSL certificate on your server.
1. Purchase the certificate
You can buy the certificate from Namecheap.com. After you buy it, you need to activate your certificate by providing your generated CSR file.
2. Generate private key and CSR file
In a Linux server, you can run the following command on the terminal to generate a private key and CSR file.
$ openssl req -new -newkey rsa:2048 -nodes -keyout mydomain.com.key -out mydoain.com.csr
When you run the command, you will be asked for Country ID, domain name, registrant email, etc. For the domain name, you have to fill it with a valid domain name that will use the certificate. For the registrant email, it is better if you use your domain email account e.g. yourname@yourdomain.com.
After you run the command, there will be mydomain.com.key (private key) and mydomain.com.csr (CSR) in your current directory.
3. Activate your certificate
Go to your purchase lists and choose to activate your certificate. Copy contents of your CSR file then paste it on provided CSR box on the website. The system will generate some certificate files. You can choose to get the certificate files by email. For Comodo certificate, you will get four files including AddTrustExternalCARoot.crt (Root CA), COMODORSAAddTrustCA.crt (Intermediate CA), COMODORSADomainValidationSecureServerCA.crt (Intermediate CA), and www_mydomain_com.crt (SSL certificate).
4. Install SSL certificate
Copy all certificate files to your server. To make your SSL certificate fully works for your domain, you need to combine the CA certificate into a single certificate. If you access your domain only from a browser, it's not necessary to combine the certificates. If you want to make your SSL secured domain can be accessed by any services, you should combine the certificates. The order of combination files should be right as the following command.
$ cat www_mydomain_com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > mydomain.com.crt
After running the command, mydomain.com.crt will contain an SSL certificate and all CA certificates. You must keep your private key and SSL certificate secure by setting up read and write permission only for root and no permission for others.
To implement the certificate into a server application, you need to set appropriate configuration for the application. For example:
Nginx
server {
listen 443;
ssl on;
ssl_certificate /path/to/ssl/mydomain/mydomain.com.crt;
ssl_certificate_key /path/to/ssl/mydomain/mydomain.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
...
}
Gitlab Community Edition
For the Gitlab server, by default, you should store the certificate in "/etc/gitlab/ssl/" with a valid domain name for the file name. If your domain name in "/etc/hostname" is "server.mydomain.com", your private key or your SSL certificate should be named "server.mydomain.com.<key/crt>". It's because the "#{node['fqdn']}" configuration variable will be translated into your hostname.
nginx['ssl_certificate'] = "/etc/gitlab/ssl/#{node['fqdn']}.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/#{node['fqdn']}.key"
5. Additional step
Some server applications need a CA certificate bundle to perform an SSL connection. You can generate a CA bundle by performing the last command without an SSL certificate. The order of combination files should be right too.
$ cat COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > ca-bundle.crt
Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you Get for more information buy certificate
ReplyDeleteThanks for publishing such best knowledge with us. You are doing such a great job. This info is very helpful for everyone. Keep it up. Thanks.Read more info about approval certification
ReplyDelete