| Enable SSL on Tomcat Apache web server |
This tutorial shows how to enable SSL support for Apache Tomcat web server.
Requirement
- Apache Tomcat 5.0
- JDK 1.5
Note: if you have JDK below 1.4, you need to install Java Secure Socket Extensions (JSSE)
Step-by-step
- Create .ketstore file
- Enter command line and change directory to your JAVA\bin folder. (Default path is: C:\Program Files\Java\jre1.5.0_12\bin)
- Type “keytool –genkey –alias tomcat –keyalg RSA and press Enter.
Where tomcat is an alias name and RSA is a key algorithm. - Type your password for the keystore. (Default password is: changeit). In this example, I’ll use password as “password�?.
- Enter general information about this Certificate. The example is the image below. In the last line, Enter key password for (tomcat) should be the same as you enter before.
Note that this information will be displayed to users who attempt to access a secure page.

- The file .keystore will be created on your account. (Currently, I use administrator account so it’ll be in C:\Documents and Settings\Administrator)

- Configure Tomcat
- Open server.xml in Tomcat\conf folder. (Default path is: C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf)
- Uncomment the paragraph below this line
.
(By removing tags below the line) - Add new attribute keystorePass=”password” to the Connector element. If you haven’t change keystore’s password, you don’t have to add this attribute.

- Change port to 443 if you want to access a page from https:// without specifies port after hostname.

- Save and restart Apache Tomcat service.
- Test the result
- Open browser and navigate to the Apache Tomcat server with https:// prefix

- There will be a pop-up window show about security alert, click Yes.

- When you see Apache Tomcat’s default page, that’s means you have success enable SSL on the server. Congratulate.
- Also, you will notice there is a key icon on the bottom right of your browser.

-
Try double click on the key to view certificate’s detail.


























August 31st, 2007 at 1:32 pm
I show the certificate like this. but I can’t see the tomcat page. error like this
The page isn’t redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
* This problem can sometimes be caused by disabling or refusing to accept
cookies.
Soon response will hope
Best
September 11th, 2007 at 6:23 pm
Sorry for late reply. I have no idea about your problem but I think the problem is from your browser about cookies. Try to run your application on different browser.
February 16th, 2008 at 11:19 pm
When I type:
keytool –genkey –alias tomcat –keyalg RSA
I get the “usage” message:
C:\Sun\SDK\jdk\jre\bin>keytool -genkey -alias tomcat -keyalg RSA
keytool usage:
-certreq [-v] [-protected]
[-alias ] [-sigalg ]
[-file ] [-keypass ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-delete [-v] [-protected] -alias
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-export [-v] [-rfc] [-protected]
[-alias ] [-file ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-genkey [-v] [-protected]
[-alias ]
[-keyalg ] [-keysize ]
[-sigalg ] [-dname ]
[-validity ] [-keypass ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-help
-identitydb [-v] [-protected]
[-file ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-import [-v] [-noprompt] [-trustcacerts] [-protected]
[-alias ]
[-file ] [-keypass ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-keyclone [-v] [-protected]
[-alias ] -dest
[-keypass ] [-new ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-keypasswd [-v] [-alias ]
[-keypass ] [-new ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-list [-v | -rfc] [-protected]
[-alias ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-printcert [-v] [-file ]
-selfcert [-v] [-protected]
[-alias ]
[-dname ] [-validity ]
[-keypass ] [-sigalg ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
-storepasswd [-v] [-new ]
[-keystore ] [-storepass ]
[-storetype ] [-providerName ]
[-providerClass [-providerArg ]] …
C:\Sun\SDK\jdk\jre\bin>
What am I missing here ?
Thanks in advace.
February 18th, 2008 at 9:09 am
That’s weird.
Try to type only “keytool -genkey” to see if it comes up something.
What is your Java version? JDK/JRE 1.x.x? May be the syntax is different on the version.
June 26th, 2008 at 4:00 pm
Hi,
My jdk/jre version is 1.5.0. and tomcat is 5.5.25
When I type When I type:
keytool –genkey –alias tomcat –keyalg RSA
I get the “usage” message:
Plz help
Thanks in advance
June 26th, 2008 at 4:55 pm
Hi,
I got it.I just modified “RSA” as shown below:
keytool –genkey –alias tomcat –keyalg “RSA”
its working fine now.
thx