This article will walk you through the different steps in creating and installing an SSL certificate on a Tomcat Webserver in a Windows Environment. The steps below will help you create a Java Keystore (JKS) which contains a Self-Signed SSL Certificate or one that has been purchased from a Certificate Authority. Our document was written and tested with Certificates purchased from Thawte or Digicert.
Here are quick links to sections within the article:
Workflow v5.0 and newer
Generate CSR and Keystore Container.
- Run the application and select Create A New Keystore and select the JKS radial.
- Right-click in the white space and select Generate Key Pair (Ctrl+G).
- Use the RSA Algorithm with 2048 key size.
- At the bottom of the window edit the Name section.
- Fill out your company information. This information will be needed to Generate the CSR. Please note that the CN field should be the Domain you are trying to secure.
- Once you have completed your entry hit OK. You will be prompted to enter an Alias name. Use tomcat and create a password. We suggest using a complex password with 8 characters. This password will be required for other steps, keep it handy. You should receive a message to confirm Key Pair Generation Successful. For this article, we will use changeit.
- Save the Keystore, for this article we will use companyssl.jks. We suggest using a folder on the root of C:\ called TomcatSSL. You will be prompted to Set a Keystore Password. Use the same one created in Step 6).
- To Export the CSR, right-click on the tomcat entry and select Generate CSR. In the new window, you will see a path to where the CSR will be stored edit the path if necessary. You will receive a message confirming the CSR Generation Successful.
- At this point, you will have a Keystore file that contains:
- Private Key (which is in the Keystore container)
- Self-Signed Certificate (which is in the Keystore container)
- CSR (separate file)
- The CSR can be uploaded to your Certificate Authority or Vendor for signing purposes. Once you have received your Certificate from your Authority Vendor use these steps to add it to your Keystore.
Alternatively, you can choose to Deploy the Self-Signed Certificate.
Append Signed SSL Certificate to Keystore
In this step, we will replace the Self-Signed Certificate in your current Keystore (companyssl.jks) with the one you have purchased from the Certificate Authority. Please download the certificate as a full chain with a CRT extension. If you did not get a full chained certificate then create one here.
- Open the Keystore container (companyssl.jks) created when Generating the CSR.
- Right-click on tomcat and select Import CA Reply and use the From File option.
- From the file explorer, locate and select the SSL Certificate you have downloaded from the Certificate Authority.
- Once the import is complete right click on tomcat and navigate to View Details and select Certificate Chain Details. You should see a waterfall of certificates with the bottom one being your Domain SSL Certificate.
- Save the Keystore file and proceed to the Deploy SSL Certificate on Tomcat.
Note: If you receive an error adding the full certificate chain to the keystore container you may still have your Self-Signed Certificate as part of your keystore. You will need to remove it. Right click on tomcat and select Edit Certificate Chain and choose Remove Certificate.
Creating an Entire SSL Certificate Trust Chain
There are many methods of creating a full chained certificate. This is an example of one method.
A full trust chain looks like:
(Your Primary SSL certificate: your_domain_name.crt)
(Your Intermediate certificate: CA.crt)
(Your Root certificate: TrustedRoot.crt)
We use Notepad++ for this section as it allows you to open multiple text files and let you flip between them.
- Open an empty text file and call it chained.crt.
- Open your Domain Certificate (PEM) in a text editor. This is the SSL certificate that your Domain is tied to. Copy the contents and paste them into the chained.crt file.
- Open the Intermediate Certificate (PEM) and copy the contents. Paste it below your Domain Certificate.
- Repeat the process again for the Root Certificate (PEM).
Note in some cases your Intermediate and Root Certificates can be downloaded as a bundle. You can use the bundle to create the full chain as long as the end result is formatted in the illustration above.
- Save the chained.crt file and proceed to add it to the Java Keystore section.
Deploy SSL Certificate on Tomcat
In Tomcat there are many different ways to configure your connector. The example below uses a hardened and secure connector which supports the following clients:
- Android 4.4.2 and later
- Firefox 32 and later
- IE 11 and later
- IE Mobile 11 and later
- Java 8 b132
- Safari 7 and later
If you would like to use a less secure connector you can use the example shown here:
For a more secure connection using the following steps:
- Shut down the Tomcat WebServer.
- Create a copy of the server.xml file located in <path-to-tomcat>/conf/.
- Open server.xml in a text editor and add the following connector:
- Save the file and start the Tomcat WebServer.
Specify the path to your keystore file in keystoreFile="c:\tomcat-ssl\companyssl.jks". If your keystore password is not "changeit" then make the change to keystorePass="changeit" in the factory element. If a specific port does not need to be specified in the URL, such as https://mycompany.com:<port>, then port 443 should be specified in the connector. This change will provide seamless integration.
Once your Tomcat Server is back online you can test the SSL on your webpage (https://mycompany.com:<port>) here: https://www.sslshopper.com/ssl-checker.html
Useful Tomcat Security Articles: