Install SSL Certificate on Tomcat Web Server
Learn how you can install an SSL certificate on an Apache Tomcat web server.
Join the DZone community and get the full member experience.
Join For FreeTomcat Web Server: SSL Certificate Installation Procedure
To successfully install your SSL Certificate on a Tomcat web server, you need to configure the root (SSL) certificate, intermediate/primary certificate, and private key within the appropriate Keystore.
- Download Certificate Files
- Import Root Certificate
- Import Intermediate Certificate
- Install SSL Certificate
Perform the following steps when installing the SSL certificate on Tomcat Web Server.
Install SSL Certificate Into the Keystore
Step 1: Download and Extract the SSL Certificate
After order completion, Certificate Authority (CA) will send an email containing a *.zip file, which includes the root, intermediate, and primary certificate files. Download and extract the files on the Tomcat Web Server directory where the Keystore was added during the Certificate Signing Request (CSR) generation process.
Note: SSL certificate will work only with the same Keystore, which was created during the CSR generation process. Also, make sure to install all certificate files in the correct order on the Keystore.
Step 2: Import Root Certificate File
During the process of installing the SSL certificate to the Keystore, the password required is the same one that you created during the CSR generation process. Now, to import the Root certificate file, enter the following command/code:
keytool -import -trustcacerts -alias root -file RootCertFileName.crt -keystore keystore.key
After entering this command, if you receive a message that says “Certificate already exists in system-wide CA Keystore under alias <…> Do you still want to add it to your own Keystore? [no]:” then select Yes.
If this process is successfully completed, it will display this message: “Certificate was added to Keystore.”
Step 3: Import Intermediate Certificate File
Add the following command/code to import the intermediate certificate file:
keytool -import -trustcacerts -alias intermediate -file IntermediateCertFileName.crt -keystore keystore.key
If this process is successfully completed, it will display this message: “Certificate was added to Keystore.”
Step 4: Installing the Primary Certificate File
Add the following command/code to install the primary certificate file:
keytool -import -trustcacerts -alias tomcat -file PrimaryCertFileName.crt -keystore keystore.key
If this process is successfully completed, it will display this message: “Certificate was added to Keystore.”
After installing the SSL Certificate file into your Keystore, the next step is the server configuration for using the Keystore file.
SSL Connector Configuration
Note: Configuration of ‘SSL Connector’ must be required for Tomcat to accept a secure connection.
In the system’s home directory, Tomcat is mainly looking for the Keystore with file name .keystore and default password as ‘changeit.’ On Unix and Linux systems, the home directory will be /home/user-name/, and for Microsoft Windows systems, it will be C:\Documents and Settings\user-name\. Users can change the file location and password if required.
1. Copy Keystore file (your-domain-name.key) into the home directory
2. Now, using any text-editor open …~/conf/server.xml file.
3. If necessary, uncomment the SSL connector.
4. Locate the SSL connector for which the new Keystore will be used. Make sure the Connector Port is 443.
5. During configuration of SSL connector, add the exact location of the Keystore file name and also the correct KeystorePass.
6. If the Tomcat version is 7.0.X or 8.0.X, then replace the KeystorePass with Keypass.
Once the connector configuration process is finished, it will look something like this:
<Connector className=”org.apache.catalina.connector.http.HttpConnector” port=”8443″
minProcessors=”5″ maxProcessors=”75″ enableLookups=”true” acceptCount=”10″ debug=”0″
scheme=”https” secure=”true”>
<Factory className=”org.apache.catalina.net.SSLServerSocketFactory” clientAuth=”false” protocol=”TLS”
keystoreFile=”/working/mykeystore” keystorePass=”password”/>
7. Save the server.xml file and restart Tomcat server.
With this step, the SSL certificate is now successfully installed the on Tomcat web server.
Published at DZone with permission of Jake Adley. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments