Configuring SSL on Tomcat

This tutorial will guide you through configuring SSL (using HTTPS protocol) on Tomcat in a matter of minutes.

I have assumed that you have already installed and are familiar with the JAVA SDK and Apache Tomcat.

For Tomcat to use HTTPS, it needs JAVA keystore. We will first generate a keystore using JAVA..

Generating a Keystore file using JAVA

Use the following command,

On Linux or OSX:
cd $JAVA_HOME/bin
On Windows:
cd %JAVA_HOME%/bin

We’re going to use the Keytool in this folder to generate the keystore.

2. Type the following command on the terminal to begin the keystore generating procedure.

keytool -genkey -alias tomcat -keyalg RSA

3. Enter the required details.

The keystore will now have been generated on the user home directory as .keystore.

Configuring SSL for Tomcat using the JAVA Keystore

  1. Find the following commented-out XML snippet.

Uncomment the snippet and edit it in the following manner,

Enter the path of your keystore file and the keystore password to the keystoreFile and keystorePass fields respectively. Also, note the port (8443) that we will be using to access Tomcat via SSL.

That’s it! You have enabled SSL on Tomcat. Tomcat can now be accessed using the HTTPS protocol.

To test it, click on https://localhost:8443.

Tomcat will be working on the default 8080 port via the HTTP protocol too. 😄

Cheers!

“Talent is a pursued interest. Anything that you’re willing to practice, you can do.”

“Talent is a pursued interest. Anything that you’re willing to practice, you can do.”