CSR AND CERTIFICATE INSTALLATION 
IN UBUNTU SERVER WITH APACHE2 

APACHE OPENSSL CSR CREATION
 

To generate a Certificate Signing Request (CSR) for Apache HTTP Server, perform the following steps. They will enable you to get the CSR to complete the order process

STEP 1: GENERATING THE KEY PAIR
 

The utility 'OpenSSL' is used to generate both Private Key (key) and Certificate Signing request (CSR). OpenSSL is usually installed under /usr/local/ssl/bin. If you have a custom install, you will need to adjust these instructions appropriately.

1.  Type the following command at the prompt in OpenSSL:

genrsa –des3 –out www.mydomain.com.key 2048 

Note: If you do not wish to use a Pass Phrase, do not use the -des3 command. It will however leave the private key unprotected.

2. Enter the PEM Pass Phrase (This MUST be remembered)

3. A 2048 RSA private key will be generated and stores in the file 'www.mydomain.com.key'

STEP 2: GENERATING THE CSR
 

1.  Type the following command at the prompt in OpenSSL:

req –new –key www.mydomain.com.key –out www.mydomain.com.csr

Note: You will be prompted for the PEM Pass Phrase if you included the "-des3" command. Type it in now.

Note: There is a known issue with Apache/OpenSSL Windows Based Installations. If you recieve an error with the above command, Please enter the following:

req -new -key www.mydomain.com.key -out www.mydomain.com.csr -config openssl.cnf

2. Input the information for the Certificate Signing Request. This information will be displayed in the certificate.

  • Common Name: Must match the URL you plan to secure exactly – is usually your fully-qualified domain name (e.g. trustzone.dk or mail.trustzone.dk). Remember the www. Is important – include it if you want to secure https://www.yoursite.com & exclude it if you want to secure https://yoursite.com.
  • Organization: The legal (officially registered) name of your organization/company include Inc., LLP., Pvt, Plc. Ltd. SARL., etc.
  • Organizational unit: The name of your department within the organization (this is often "IT," "Web," or is just left blank).
  • City/locality: The city or town in which your organization is located.
  • State/province: The state in which your organization is located.
  • Country: Click here for the official list of ISO country codes for this field. 

    Note: DO NOT Enter the following: 'Email Address'; 'A challenge password' & 'An optional company name'.

3. Please verify the CSR, to insure all information is correct. Use the following command:

req -noout -text -in www.mydomain.com.csr

4. The CSR will now be created, and can be submitted via the website

You are now ready to submit your CSR for the certificate you wish to install.

 

 

SSL CERTIFICATE INSTALLATION IN UBUNTU SERVER WITH APACHE2
 

These instructions were created using Ubuntu server 12.x. Additional help is available at: https://help.ubuntu.com/.

 

1.  Copy the certificate files to your server.

Download your Intermediate and SSL certificate (your_domain_name.crt) files from your portal, then copy them to the directory on your server where you will keep your certificate and key files. Make them readable by root only.

2. Find the Apache config file to edit.

Ubuntu's Apache configuration file for your ssl site is typically found in /etc/apache2/sites-enabled/your_site_name. If it is not found in the 'sites-enabled' folder, you would need to run the command sudo a2ensite your_site_name.

If you open the file with a text editor, you should be able to find <VirtualHost> blocks which contain Apache settings.
 

3. Identify the SSL <VirtualHost> block to configure.

If you need your site to be accessible through both secure (https) and non-secure (http) connections, you will need a two separate files in /etc/apache2/sites-enabled/. One will be for port 80 and the other file for port 443. Configure it for SSL as described in step 4.

If you only need your site to be accessed securely, configure the existing virtual host for SSL as described in step 4.
 

4. Configure the <VirtualHost> block for the SSL-enabled site.

5. Below is a very simple example of a virtual host configured for SSL. The parts listed in bold are the parts that must be configured for the SSL configuration and they may be spread out throughout the file:

<VirtualHost 192.168.0.1:443>
DocumentRoot /var/www/
SSLEngine on SSLCertificateFile /path/to/your_domain_name.crt
SSLCertificateKeyFile /path/to/your_private.key
SSLCertificateChainFile /path/to/DigiCertCA.crt
</VirtualHost>

Adjust the file names to match your certificate files:

  • SSLCertificateFile should be your TRUSTZONE certificate file (eg. your_domain_name.crt).
  • SSLCertificateKeyFile should be the key file generated when you created the CSR.
  • SSLCertificateChainFile should be the TRUSTZONE intermediate certificate file.

If the SSLCertificateChainFile directive does not work, try using the SSLCACertificateFile directive instead.
 

6. Test your Apache config before restarting.

It is always best to check your Apache config files for any errors before restarting, because Apache will not start again if your config files have syntax errors. Run the following command (it is apache2ctl on some systems):

apachectl configtest
 

  • Restart Apache

You can use apachectl commands to stop and start Apache with SSL support:

apachectl stop
apachectl start

 

Note: If Apache does not start with SSL support, try using "apachectl startssl" instead of "apachectl start". If SSL support only loads with "apachectl startssl" we recommend you adjust the apache startup configuration to include SSL support in the regular "apachectl start" command. Otherwise your server may require that you manually restart Apache using "apachectl startssl" in the event of a server reboot. This usually involves removing the and tags that enclose your SSL configuration.

 

CONFIGURATION AND USEFUL COMMANDS
  • Install Apache2

Required for SSL certificates to be used:

sudo apt-get install apache2
 

  • Enable SSL Module

'default-ssl' can be replaced by the real site name you set up in /etc/apache2/sites-available/

sudo a2enmod ssl

Once the site listed in the command above is enabled with that command, the site will appear in /etc/apache2/sites-enabled.
 

  • Apply SSL Module to Site

sudo a2ensite default-ssl
sudo /etc/init.d/apache2 restart

 

  • Cipher Suite

Once the a2enmod ssl command has been run, you can edit the ssl.conf file in /etc/apache2/mods-enabled.

If the a2enmod command has not been run yet, you can preconfigure the ssl.conf file in /etc/apache2/mods-available.

Last updated: July 26, 2017