1. Generate Certificate Signing Request (CSR).
Before you can purchase and install an SSL Certificate, you must generate a CSR on the server. This file contains your server and public key information needed to generate a private key. You can generate a CSR directly from the Apache command line:
- Run the OpenSSL utility. It is usually located in/usr/local/ssl/bin/
- Create a pair of keys by entering the following command:
openssl genrsa –des3 –out www.mydomain.com.key 2048
- Create a passphrase. The passphrase must be entered every time you interact with the key.
- Run the CSR creation process. Enter the following command when prompted to create a CSR file:
openssl req –new –key www.mydomain.com.key –out www.mydomain.com.csr
- Fill in the requested information. You must enter a two-digit country, state or province code, city name, full company name, section name (for example IT or Marketing), and a common name (usually a domain name).
- Create a CSR file. Once the information is entered, run the following command to generate a CSR file on the server:
openssl req -noout -text -in www.mydomain.com.csr
2. Order your SSL certificate.
There are several internet services that offer SSL certificates. Make sure to only order from reputable services, as your and your customers’ safety is at stake here. There are several well-known services for example DigiCert, Symantec, GlobalSign and many more. The best service varies greatly and depends on your needs (number of certificates, company solutions, etc.).
- You must upload the CSR file to the certificate service when ordering it. This file will be used to generate a certificate for your server.
3. Take your certificate.
—–BEGIN CERTIFICATE—–
[Encoded Certificate]
—–END CERTIFICATE—–
- If the certificate is a text file, you must convert it to a .crt file before uploading.
- Check the downloaded key. There must be 5 hyphens “-” on the side of the BEGIN CERTIFICATE or END CERTIFICATE line. Also ensure that there are no extra spaces or line breaks included in the key.
4. Upload the certificate to the server.
The certificate must be placed in a folder dedicated to certificates and key files. An example of a certificate location is /usr/local/ssl/crt/. All certificates are in the same folder.
5. Open the “httpd(dot)conf” file from a text editor.
Some versions of Apache have an ssl(dot)conf file for the SSL certificate. Just edit one of the files if there are two files. Add the following line to the Virtual Host section:
SSLCertificateFile /usr/local/ssl/crt/primary.crt SSLCertificateKeyFile /usr/local/ssl/private/private.key SSLCertificateChainFile /usr/local/ssl/crt/intermediate.crt
- Save changes to a file when finished. Re-upload the file if necessary.
6. Reboot the server.
Once the files have changed, you can start using your SSL certificate by restarting the server. Most versions can be restarted by entering the following command:
apachectlp stop apachectl startssl
7. Test certificate.
Use various web browsers to test if your certificate is working properly. Connect to your website using “https://” to force an SSL connection. You’ll see a lock icon in the address bar, usually with a green background.