Wednesday, September 16, 2009

How to configure tomcat with SSL

Recently i noticed that the information available in internet to configure tomcat with ssl is confusing, so i'm going to explain what i did in order to get this work in Windows XP.
i used Tomcat 6

first of all i created a .keystore file using the java utility as follows

(i had installed java jre in that path, if you have installed in other location, you can use JAVA_HOME to get there if it were defined)

C:\Program Files\Java\jre6\bin>keytool -genkey -alias tomcat -keyalg RSA -keypass puki -keystore my.keystore -storepass puki

i'm using the same password for the keypass and sotrepass since i read that if they were different, you would receive an IO Error

after executing the command, a set of questions appear, answer all of them. When you're done with that, your keyfile (my.keystore in my case) will be created in the directory where you ran the command (C:\Program Files\Java\jre6\bin in my case) i moved this file, and put it inside the webapps directory under my tomcat home (C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps)

Then i edited the file
C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\servers.xml

NOTE: if you installed tomcat in another location, the path might be different but you can always use CATALINA_HOME to get there

i added this lines to the file






after that, i just started tomcat, opened a web browser and tried the URL
https://localhost:8443


and when this window appeared




i knew that i had finished.


2 comments: