First of all, we must create a Keystore file using Java. Go to your JDK folder: cd $JAVA_HOME/bin. Now, create the keystore file: keytool -genkey -alias tomcat -keyalg RSA -keystore. Bare in mind that the password for the keystore must be the same as the key password. This is a tomcat limitation that I didn’t find anywhere. Took me a whole morning to find out. If everything is correct, you should have the .keystore file in the folder you where in (JDK/bin). The next step is to copy this .keystore file wherever you want it to be.
There is a possibility to change the password for the key file using the following command: keystore -keypasswd -alias tomcat -keystore
Now, let’s move on. Open your server.xml file. Inside the conf folder, in $CATALINA_HOME. You have to declare a new Connector:
Our last step to follow is to configure the web.xml file for our app. Then we will be able to run SSL. It should be inside your webapps/appFolder folder. Insert the following lines after
If you want to quit SSL, just change CONFIDENTIAL to NONE, so you don’t have to delete all the code written. Hope you found it interesting.
Resources:
Resource 1
Resource 2