posted on December 20, 2007 in Linux
with 4 Comments
Had to SSL on a test server running Tomcat 5 yesterday. This is how I did it.
- >cd $CATALINA_HOME
- > $JAVA_HOME/keytool -genkey -alias tomcat -keyalg RSA -keystore mycert.jks
- Enter keystore password: changeit
- What is your first and last name? [Unknown]: Danesh Manoharan
- What is the name of your organizational unit? [Unknown]: IT
- What is the name of your organization? [Unknown]: My Comp.
- What is the name of your City or Locality? [Unknown]: KL
- What is the name of your State or Province? [Unknown]: KL
- What is the two-letter country code for this unit? [Unknown]: MY
- US Is CN=Danesh Manoharan, OU=IT, O=”My Comp.”, L=KL, ST=KL, C=MY correct? [no]: yes
- Enter key password for (RETURN if same as keystore password): Hit Enter.
Tomcat will assume the password is “changeit” by default so it’s advised to leave it that way. Now let’s tell Tomcat to use the keystore file.
- cd $CATALINA_HOME/conf/
- vi server.xml
- Look for “<!– Define a SSL HTTP/1.1 Connector on port 8443 –>”. Remove the <!– –> comments indicator and add the keystore info.
<!– Define a SSL HTTP/1.1 Connector on port 8443 –>
<Connector port=”443” maxHttpHeaderSize=”8192″
maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
acceptCount=”100″ scheme=”https” secure=”true”
clientAuth=”false” sslProtocol=”TLS” />
Time to restart Tomcat and test.
- cd $CATALINA_HOME/bin/
- ./shutdown.sh to make sure Tomcat is down.
- ./startup.sh to start Tomcat.
- Fire up your browser and test your new https site. https://localhost/