How to Make Tomcat Use Secure HTTP (HTTPS)

Step 1. Generate a self-signed certificate

Use the following UNIX command to create a keystore.

keytool -genkey -alias tomcat -keyalg RSA -keystore server.keystore -keysize 2048 -validity 60

You will be asked to set a passphrase; let's call it MY_PASS.

Copy the newly created server.keystore file to an appropriate location.

Step 2. Update the Tomcat server config

Add the following lines in server.xml. Note that you must customize the keystorefile and keystorePass attribute settings.

To connect to the server using HTTPS, you must specify port 8443 in the URL. For example, like this:

http://localhost:8443/Foo/

Further reading


Valid HTML 4.01 Strict Valid CSS!