Monday, September 18, 2006

Enabling SSL in Tomcat

I have done this in windows, didn’t tried this on Linux machine.
Its easy and simple, just follow these steps:

  1. First we will need to generate a keystore file, containing a self-signed certificate. Execute the following command on the prompt

    %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA

  2. Open file <tomcat-home-dir>\conf\server.xml.
  3. Find and uncomment the following code:

    <Connector port="8443"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" disableUploadTimeout="true"
    acceptCount="100" debug="0" scheme="https" secure="true"
    clientAuth="false" sslProtocol="SSL" />

  4. Change the value of the port if you need.
  5. In this clientAuth is set to false. Change its value to true if you want client authentication. In this case if client authentication fails then it won’t let you to proceed. Set it then it to want if you you want to proceed even if authentication fails.
  6. If the sslProtocol is set to TLS then set it to SSL. TLS is an IBM’s implementation and is not compatible with some browsers.
  7. Now try opening https://localhost:8443. It should display the tomcat’s home page. If it is not installed, try running some other application that you have deployed with https.

For more details you can view the SSL documentation that comes with the tomcat on your local machine or you can logon to the website http://localhost:8080/tomcat-docs/ssl-howto.html.


E ñ j Ô ÿ !!!