Pages

Tuesday 7 August 2012

Generate CSR for Apache-SSL



To generate a CSR on Apache, perform the following steps:
To generate a CSR, a key pair must be created for the server. These two items are a digital certificate key pair and cannot be separated. If the public/private key file or password is lost or changed before the SSL certificate is installed, the SSL certificate will need to be re-issued. The private key, CSR, and certificate must all match in order for the installation to be successful.

The following sequence of commands will generate a 2048 bit key, encrypt it using the triple-DES cipher, and create a CSR based upon it (they assume that openssl is in the path - if not then prefix the openssl command with the path to the binary). It is recommended to use the domain name that will be used for the certificate as the core of the filenames. Also make sure that any existing keys and CSR's are NOT overwritten.


Step 1: Generate Private Key


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 the utility was installed elsewhere, these instructions will need to be adjusted accordingly.

Type the following command at the prompt:

openssl genrsa -des3 -out www.yourdomain-example.com.key 2048




This command generates a 2048 bit RSA private key and stores it in the file examplePrivateKey.key.

Note: For all SSL certificates, the CSR key bit length must be 2048.

When prompted for a pass phrase: enter a secure password and remember it, as this pass phrase is what protects the private key. Both the private key and the certificate are required to enable SSL.

NOTE: To bypass the pass phrase requirement, omit the -des3 option when generating the private key. If the private key is left unprotected, RapidSSL recommends access to the server be restricted so that only authorized server administrators can access or read the private key file.

Step 2: Generate the CSR

Type the following command at the prompt:

openssl req -new -key examplePrivateKey.key -out exampleCSR.csr



This command will prompt for the following X.509 attributes of the certificate:




Country Name: Use the two-letter code without punctuation for country, for example: US or CA.

State or Province: Spell out the state completely; do not abbreviate the state or province name, for example: California

Locality or City: The Locality field is the city or town name, for example: Berkeley. Do not abbreviate. For example: Saint Louis, not St. Louis

Company: If the company or department has an &, @, or any other symbol using the shift key in its name, the symbol must be spelled out or omitted, in order to enroll. Example: XY & Z Corporation would be XYZ Corporation or XY and Z Corporation.

Organizational Unit: This field is optional; but can be used to help identify certificates registered to an organization. The Organizational Unit (OU) field is the name of the department or organization unit making the request. To skip the OU field, press Enter on the keyboard.

Common Name: The Common Name is the Host + Domain Name. It looks like "www.rapidssl.com" or "rapidssl.com".

No comments:

Post a Comment