Today, I will be showing you how easy is it to install SSL for Apache Tomcat 4.1 in a Windows platform.
Make sure your tomcat is working and the java j2sdk1.4.2 or later version is installed in your machine.
Self-Signed Certificate creation
Open a windows command prompt. Navigate to the %JAVA_HOME% or the java installation directory where in my machine I have placed this in C:\java\j2sdk1.4.2_18.
Then change the directory to bin folder and do a list with dir/w command
Here you should see the keytool.exe.
Specify the argument needed in the java keytool as below. This vary on the setting needed for your SSL
C:\java\j2sdk1.4.2_18\bin>keytool -genkey -alias ssltest -keyalg RSA
You will be then requested to enter in your keystore password. This password should be specified later in your tomcat server.xml configuration file. For this example I’m entering the password as “testingssl”.
Enter keystore password: testingssl
Once the password entered. Then you will be requested to answer few question. Just follow mine and change the answers based on your requirement. You can find further information regarding this question in the java keytool help documents.
What is your first and last name?
[Unknown]: http://www.kishurtest.com <— Please enter your site name here.
What is the name of your organizational unit?
[Unknown]: Kishur Company
What is the name of your organization?
What is the name of your City or Locality?
[Unknown]: Kuala Lumpur
What is the name of your State or Province?
[Unknown]: Wilayah Persekutuan
What is the two-letter country code for this unit?
Is CN=www.kishurtest.com, OU=Kishur Company, O=Outsourcing, L=Kuala Lumpur, ST=Wilayah Persekutuan, C=MY correct?
Enter key password for <ssltest>
(RETURN if same as keystore password): testingssl <—This is the same password as on top.
If you have successfully completed the above then .keystore file will be created in your windows home directory.Example : C:\Documents and Settings\Kishur
Now we need to configure the Tomcat in order to read our SSL settings.
SSL Configuration in Tomcat
Navigate to your Tomcat configuration directory.
Example : C:\Program Files\Apache Software Foundation\Tomcat 4.1\conf
Open your server.xml file found in the tomcat configuration forlder. By default the SSL configuration will be commented. Since your will be using SSL, uncomment the below lines and add in the attribute as below:
<!– Define a SSL Coyote HTTP/1.1 Connector on port 8443 –>
port=”443″ enableLookups=”true” scheme=”https” secure=”true”
acceptCount=”100″ useURIValidationHack=”false” disableUploadTimeout=”true”
clientAuth=”false” sslProtocol=”TLS” keystorePass=”testingssl” />
Once you have done this. Restart the tomcat service in your machine. Then try to access the page by opening a browser and accessing to your page with https://