Introduction: Using this blog you will able to enable the Secure Socket Layer(SSL) in the apache-tomcat web server to access the application using HTTPS. This blog is applicable when you are using self-sign certificate and Helical Insight is being used in a stand alone mode not embedded within a third party application.
Prerequisite:
1. Java 1.8+ should be installed.
2. Apache-tomcat version 7 or more(preferred version 7.0.47) should be installed.
3. Any web application should be installed for which you want to enable HTTPS.
Example: Helical Insight application.
4. Application should be in running status on the apache-tomcat server.
Setting up SSL for Tomcat can be divided into two main tasks:
1. Creating a functional keystore
2. Configuring the tomcat connectors and applications.
Step 1 – Creating the Keystore
The keys Tomcat will use for SSL transactions are stored in a password-protected file called “keystore.” The first step to enabling SSL on your server is to create and edit this file. You can create this file in one of two ways – by importing an existing key into the keystore, or by creating an entirely new key.
A program called “keytool.exe”, which is included with your Java JDK(You can find “keytool.exe” inside “C:\Program Files\Java\jdk\bin” path), will do the actual work of creating your new keystore. To create a new keystore using this program, enter the following command at the command-line:
$JAVA_HOME/bin/keytool -genkey -alias [youralias] -keyalg RSA -keystore [/preferred/keystore/path]
Use an [alias] and [path] of your choice.
Example: C:\Program Files\Java\jdk1.6.0_21\bin> keytool.exe –genkey –alias localhost –keyalg RSA -keystore c:\localhostgeneratedkey
Once you fire the above command, keytool will ask you to enter the password you want to use for the keystore. Choose any password according to your wish.
After you choose the keystore password, you need to enter the information required for the Certificate, such as your company and your name. Make sure this information is accurate.
At last, keytool will ask you to specify the key password, which is the password specific to this specific certificate. Rather than entering anything at this prompt, just press ENTER.
This will cause keytool to set the key password to a value equivalent to the keystore password. Matching passwords are REQUIRED for Tomcat to access the certificate. If you choose two different passwords, any attempts to access the keystore will result in a crash.
After following above steps, you should have keystore file, located in the directory which you have chosen.
If you have entered the details as above example, then you should have a usable keystore file named localhostgeneratedkey located in C:\.
Step 2 – Configuring Tomcat’s SSL Connectors
Tomcat’s global Connector options are configured in Tomcat’s main configuration file, “$CATALINA_BASE/conf/server.xml”, now you can open this file. By default, we are looking to connect on port 8443, search for this port, until you come across 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"/>
-->
You’ll notice that the comment enclosing this connector talks about a choice between APR and JSSE configurations. This refers to the implementation of SSL you are intending to use. JSSE, which is Tomcat’s default configuration, is supported by default, and included in all JDKs after version 1.4. If you don’t know what APR is, you only need to uncomment this entry, and add some additional information to allow Tomcat to find your keystore:
<Connector port="8443" maxThreads="150" scheme="https" secure="true" SSLEnabled="true" keystoreFile="path/to/your/keystore" keystorePass="YourKeystorePassword" clientAuth="false" keyAlias="yourAlias" sslProtocol="TLS"/>
Example: <Connector port=”8443″ protocol=”HTTP/1.1″ SSLEnabled=”true” maxThreads=”150″ scheme=”https” secure=”true” clientAuth=”false” sslProtocol=”TLS” keystoreFile=c:\ localhostgeneratedkey keystorePass=”localhost”/>
After following all above steps, restart the apache-tomcat to reflect the changes.
You can now access the application using https://”DomainName”:8443/”applicationcontextName”
https://localhost:8443/hi-ee