The following instructions will guide you through the SSL installation process on Tomcat. If you have more than one server or device, you will need to install the certificate on each server or device you need to secure.
What You’ll Need?
- Your server certificate
This is the certificate you received from the CA for your domain. - Your intermediate certificates
These files allow the devices connecting to your server to identify the issuing CA. There may be more than one of these certificates. If you got your certificate in a ZIP folder, it should also contain the Intermediate certificate(s), which is sometimes referred to as a CA Bundle. If not, download the appropriate CA Bundle for your certificate. - Your private key
This file should be on your server, or in your possession if you generated your CSR from a free generator tool. On certain platforms, such as Microsoft IIS, the private key is not immediately visible to you but the server is keeping track of it.
Installation Instructions:
- Convert your certificate files
Convert your certficate files from PEM (.cer or .crt) to PKCS#7 (.p7b) Format. You can easily do this on your own system by running below OpenSSL command.openssl crl2pkcs7 -nocrl -certfile certificate.cer -out certificate.p7b -certfile CACert.cer
- Access your Directory
Go to the same Directory where you previously saved the keystore and Certificate Signing Request (CSR).
Note: You must install the certificate on the same keystore and under the same “alias name.” If not, you will encounter problems during installation and may have to start over. - Run the Install command
Install the certificate in the same keystore by running the following command:keytool -import -trustcacerts -alias server -file your_file_name.p7b -keystore your_domain_name.jks
Note: Replace “your_domain_name” with the primary domain you will be securing and “your_file_name” with the PKCS#7 file name that you recently converted & saved. - Check confirmation message
You should receive this confirmation message: “Certificate reply was installed in keystore.” - Enter Y
Enter Y or Yes when prompted to trust the certificate. Note: Your keystore now has the correct certificate files to use SSL/https on your Tomcat server. - Configure an SSL Connector
Now, you need to configure an SSL connector that will enable the server to accept secure connections. - Open the .xml file
Open the .xml file from your server in a text editor such as Notepad.
Note: The .xml file is generally stored in the conf folder in your server’s home directory. - Locate your connector
Locate the connector that you intend to use the new keystore to secure.
Note: Typically, the connector used has port 443 or 8443. - Uncomment the connector
Uncomment the connector – if necessary – by removing the comment tags (<!– and –>). - Enter the keystore filename and password
Enter the correct keystore filename and password. See our example below:< Connector port="443" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" acceptCount="100" scheme="https" secure="true" SSLEnabled="true" clientAuth="false" sslProtocol="TLS" keyAlias="server" keystoreFile="/home/user_name/your_domain_name.jks" keystorePass="your_keystore_password" />
Note: If you are using a version prior to Tomcat 7, please change the word “keystorePass” to “keypass”. - Save your changes
Save all changes made to your .xml file. - Restart Tomcat
Restart your Tomcat server to complete the SSL installation process.
Congratulations! You’ve successfully installed your SSL certificate! To check your work, visit the website in your browser at https://yourdomain.tld and view the certificate/site information to see if HTTPS/SSL is working properly. Remember, you may need to restart your server for changes to take effect.