Generating CSR and Private Key on Apache ModSSL Server

This guide demonstrates the process of generating a Certificate Signing Request (CSR) and Private Key from the command line on Apache ModSSL server.

To generate the CSR and private key in Apache modSSL, follow the instructions below:

The utility "openssl" is used to generate the key and CSR. This utility comes with the OpenSSL package and is usually installed under /usr/local/ssl/bin. If you have installed them elsewhere you will need to adjust these instructions appropriately.

First you have to know the Fully Qualified Domain Name (FQDN) of the website for which you want to request a certificate. When you want to access your website through then the FQDN of your website is; therefore, your common name will be

Generate the Key with the following command:

$ openssl genrsa -des3 -out 2048

This command will generate 2048 bit RSA Private Key and stores it in the file

It will ask you for a pass phrase: use something secure and remember it. Your certificate will be useless without the key. If you don't want to protect your key with a pass phrase (only if you absolutely trust that server machine, and you make sure the permissions are carefully set so only you can read that key) you can leave out the -des3 option above. Also leave out -des3 option if you are running Apache on Windows as it does not work on Windows.

Backup your file and make a note of the pass phrase. A good choice is to backup this information onto a diskette or other removeable media.

Note:  If you are attempting to request an Extended Validation certificate, ensure that 2048 is selected as your key-bit length.

Generate the CSR with the following command:

$ openssl req -new -key -out

This command will prompt you for the X.509 attributes of your certificate. Remember to give the name when prompted for 'Common Name (eg,'.

Do not enter your personal name here. We are requesting a certificate for a webserver, so the Common Name has to match the FQDN of your website (a requirement of the browsers)

You will now have a RSA Private Key in and a Certificate Signing Request in

The file is your secret key, and must be installed as per the instructions that will come when your certificate is issued. The file is your CSR, and the important bit looks something like this:


The CSR in is what you now paste into the appropriate online order form.

Please take a note of the format above.

Please Note: Generating the private key with the passphrase will mean that the same passphrase will need to be entered after restarting the server.

The utility (openssl) that you use to generate the RSA Private Key (Key) and the Certificate Signing Request (CSR) comes with Openssl and is usually installed under the directory SSL_BASE/bin where SSL_BASE is the path you specified for building Apache+mod_ssl either with the --with-openssl option or the SSL_BASE variable.

  • csr, private key, apache ssl, openssl
  • 149 Users Found This Useful
Was this answer helpful?

Related Articles

View Server PHP Environment with phpinfo.php

The phpinfo() function outputs a huge amount of information about the system you're using, such...

How to Change Root Password Using SSH

This article explains the method of changing the root password on a Linux Server using SSH....

How to Create Sudo User on CentOS

This article provides step-by-step setup guide for adding Sudo user to CentOS system. The sudo...

How to Use Sudo

This article provides a guide to using a Sudo user on CentOS server. From the command line,...

Set Server Time Zones with Timedatectl

This article provides a guide to setting the server time and server time zone settings using...