Ask a Question

General Information ID : INFO810

Managed PKI for SSL - Certificate Signing Request (CSR) Generation Instructions for Tomcat

Description

To generate a CSR, you will need to create a key pair for your server. These two items are a digital certificate key pair and cannot be separated. If you lose your public/private key file or your password and generate a new one, your SSL Certificate will no longer match. You will have to request a new SSL Certificate and may be charged.
 
Step 1: Create a Keystore and Private Key
 
NOTE: All certificates that will expire after December, 2013 must have a minimum 2048 bit key size
 
Please use a recent version of the JDK for best security practices
 
If you are running a 1.3 JVM, download JSSE 1.0.2 (or later) from http://www.oracle.com/technetwork/java/index.html.

Make it either an installed extension on the system or set an environment variable JSSE_HOME that points to the directory where JSSE is installed.
 
  1. Create a certificate keystore and private key by executing the following command:

    Unix: $JAVA_HOME/bin/
    Windows: C:Program FilesJavajdk1.7.0_26in

    keytool -genkey -alias <your_alias_name> -keyalg RSA -keystore <your_keystore_filename> -keysize 2048


    For example:


     
  2. Enter and re-enter a keystore password.  Tomcat uses a default password of changeit.  Hit Enter if you want to keep the default
    password. If you use a different password, you will need to specify a custom password in the server.xml configuration file.
     
  3. This command will prompt for the following X.509 attributes of the certificate:



     
    • First and last name (Common Name (CN)): The fully-qualified domain name to which your certificate will be issued.
    • Organizational Unit (OU): 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.
    • Organization (O): The full legal name of your company.. 
    • Locality or City (L): Usually the city of your organization's main office, or a main office for your organization.
    • State or Province (S): Enter the full name of your state or province.
      Note: Make sure the State or Province is not abbreviated (e.g. California).
    • Country Name (C): Enter the two-character abbreviation of country in which organization resides (e.g. US).
       
  1. When prompted for the password for the private key alias, press Enter.  This will set the private key password to the same password used for the keystore from the previous step. 
    Make note of the private key and the keystore password.  If lost they cannot be retrieved.

     

    For further information, please refer to the Tomcat Web site.
 
Step 2: Generate a CSR
 
  1. Run the following command to generate the CSR:

    keytool -certreq -keyalg RSA -alias <your_alias_name> -file certreq.csr -keystore <your_keystore_filename>

    For example:



    NOTE: CSRs generated using the MD5 digest (signature) algorithm are no longer allowed.
    CSRs must be generated using SHA-1 or SHA-256/384/512


    Outdated versions of Java SDK may use the MD5 signature hash under RSA. It is recommended to upgrade to a more recent version of the Java SDK.

    Alternatively, try to specify SHA-1 using the following command:

    keytool -certreq -keyalg RSA -alias <your_alias_name> -file certreq.csr -keystore <your_keystore_filename> -sigalg SHA1withRSA

    For example:


     
  2. Verify your CSR

  3. Create a copy of the keystore file. Having a back-up file of the keystore at this point can help resolve installation issues that can occur when importing the certificate into the original keystore file. 
     
  4. To copy and paste the file certreq.csr into the enrollment form, open the file in a text editor that does not add extra characters (Notepad or Vi are recommended).

    Make sure to include the "BEGIN CERTIFICATE REQUEST" and "END CERTIFICATE REQUEST" header and footer.

    The text file should look like this:

    -----BEGIN CERTIFICATE REQUEST-----

    [encoded data]

    -----END CERTIFICATE REQUEST-----


Once the certificate has been issued, follow the steps from this link to install the certificate on your server:

  1. Install the SSL Certificate in PKSC#7 format.  This format makes installation easier as it is a bundle of certificate and intermediate.
     
  2. To install the SSL Certificate in X.509 format.  This format also works but it will require separate import commands for each file.