Enabling HTTPS in Tomcat

To enable https in Tomcat, you'll first need to create a self-signed certificate. Open a command window, go to the main Tomcat directory, and issue the command:

%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA -keystore mykeystore
Here, %JAVA_HOME% is the top-level directory of your Java installation. It will ask you to choose a password and then answer a series of questions. If it succeeds, it will leave behind a file called "mykeystore" (or whatever name you choose).

Next, you need to edit the server.xml file in Tomcat's conf directory. Look for an entry that looks like this:

    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->
Notice that the entry is commented out. Remove the comment delimiters and edit slightly so that it looks like this:

    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->

    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="mykeystore" keystorePass="mypassword" />

Of course, you should supply appropriate values for keystoreFile anad keystorePass.