This quick guide walks you through the crucial aspects of a proper Tomcat SSL installation. First, you will learn how to generate a CSR code for you Tomcat server. Second, you will master how to install an SSL Certificate in Tomcat. Finally, you will discover a bit of Tomcat history, and the best place to buy an SSL certificate for your Tomcat server.
Generate a CSR code for Tomcat
CSR stands for Certificate Signing Request, a block of text containing current details about your domain ownership and company. All buyers of commercial SSL certificates must submit the CSR to their Certificate Authority to pass the SSL validation and obtain the certificate.
We’ll use the keytool commands to generate your private key and the CSR code. Please, follow the steps below:
- Your first step is to create a keystore for your private key. To do it, launch a command line interface and run the following command:
keytool -genkey -keysize 2048 -keyalg RSA -alias ssldragon -keystore example.jks
Note: Don’t forget to replace “example” with the primary domain name you want to secure. You may use any custom alias. For this demonstration, we’ve used ssldragon.
- Create a password for the kyestore. Remember this password, or write it down. You’ll need it soon
- Next, you need to answer the following questions:
- What is your first and last name? – instead of writing your initials, please specify the Fully Qualified Domain Name (FQDN) you want to protect with an SSL Certificate (e.g. ssldragon.com). If you have a Wildcard certificate, add an asterisk in front of the domain (e.g., *.ssldragon.com)
- What is the name of your organizational unit? – For Business and Extended Validation Certificates, enter the department in charge of web security (e.g., IT or Web Administration). For Domain Validation Certificates, enter NA instead
- What is the name of your organization – type the officially registered name of your company. Use only alphanumerical characters (e.g., GPI Holding LLC)
- What is the name of your City or Locality? – submit the full name of your city, town or locality. (e.g., San Jose)
- What is the name of your State or Province? – provide the full name of the state or region where your business is registered (e.g., California)
- What is the two-letter country code for this unit? – You can find the full list of country codes here. Make sure the country you specify is the legal residence of your organization (e.g., US)
- The command will ask you to confirm your information.
Is CN=ssldragon.com, OU=IT, O=GPI Holding LLC, L=San Jose, ST=California, C=US correct?Double-check your answers, and type y or yes to continue
- After you’ve generated the keystore with the private key, run the following command to create the CSR code:
keytool -certreq -keyalg RSA -alias ssldragon -file example.csr -keystore example.jks
- Replace ssldragon and example.jks with your corresponding details
- Enter the keystore password (you created it in step 2)
- Your CSR code is ready. It resides in the example.csr file. You can open it with any text editor of your choice and copy-paste the whole content during your buying order. To ensure you don’t miss a line, use the ctrl+a hot key to select the entire text.
After the Certificate Authority validates your request and sends you the SSL files, proceed to the SSL installation.
Install an SSL Certificate in Tomcat
Prepare your SSL certificate files. Depending on your Certificate Authority, your SSL files may be in PKCS#7 format (.p7b or .cer extensions) or PEM format (.crt extension). Determine your files’ format and follow the instructions below:
As it already contains the required root and intermediate certificates, all you have to do is run the following command to add it into the keystore:
keytool -import -trustcacerts -alias ssldragon -keystore example.jks -file example.p7b
Note: Replace ssldragon and example with your alias and file names.
If you see the message “Certificate reply was installed in keystore”, you’ve successfully imported the certificate. You can use the following command to check the details of your certificate:
keytool -list -keystore example.jks –v.
You have to import all the necessary certificate files separately in the correct order. Run the commands below for each certificate type:
- Root Certificate –
keytool -import -alias root -keystore example.jks -trustcacerts -file root.crt
- Intermediate Certificate –
keytool -import -alias intermediate -keystore example.jks -trustcacerts -file intermediate.crtIf your certificate includes several intermediate certificates, you should import all of them in the keystore. Please, follow the correct sequences. For example, for Sectigo PositiveSSL Certificate you should import:
- The certificate signed by the root (e.g. crt)
- The intermediate certificate (e.g. crt)
- The intermediate certificate that signs the certificate issued for your domain (e.g. crt)
- Primary Certificate (the one issued for your domain) – keytool -import -alias ssldragon -keystore example.jks -file example.crt
Note: Replace the alias with the your own one.
After the import, your next step is to edit the Tomcat configuration file. By default, it’s called server.xml and resides in the Home_Directory/conf folder.
- Locate the configuration file
- You should see a few lines of code similar to the example below:
<Connector port="443" protocol="HTTP/1.1"
scheme="https" secure="true" clientAuth="false"
- Please change the parts in bold. For keystoreFile parameter, specify the directory of your keystoreFile. For keystorePass attribute, enter your keystore password.
Note: If this is your first Tomcat configuration, the keystoreFile and kyestorePass lines may be missing. You will have to manually add them. Also, you will need to uncomment the connector by removing the comment tags (<!– and –>).
- Save your .xml file and restart your Tomcat server
- Congratulations! You’ve successfully installed an SSL certificate on Tomcat.
Test your Tomcat SSL installation
After you install an SSL certificate in Tomcat, several unnoticed errors may creep in and affect the performance of your certificate. Make a habit of checking your SSL installation regularly. Use one of these high-end SSL tools to get instant scans and reports.
Tomcat server history and versions
Tomcat Server, officially known as Apache Tomcat, is an open-source Java servlet container developed by the Apache Software Foundation (ASF). The original author of Tomcat is James Duncan Davidson, an American photographer, and developer. According to Apache’s wiki page, Davidson picked the “Tomcat” name because it represents an animal that could take care of itself and fend for itself.
Listed below are all the major versions of Tomcat:
- 2.0 – the initial Tomcat release in 1998
- 4.1 – first apache release with Catalina (a servlet container), Coyote (an HTTP connector) and Jasper (a JSP engine)
- 7-0 – released in 2011, it is the older version still supported
- 8.5 – released in 2016, it is one of the 3 versions still receiving updates
- 9.0 – released in 2018, it is the latest Tomcat version, at the time of writing this article.
Where to buy the best SSL Certificate for Tomcat?
SSL Dragon is your one-stop place for all your SSL needs. We’re partners with the best Certificate Authorities on the market, and offer the most competitive prices across the entire range of our SSL products. All our certificates are compatible with the Tomcat server. Whether you want to secure a blog or a network of e-commerce sites, we’ve got you covered. Below are the types of SSL certificates available at SSL Dragon:
- Domain Validation
- Business Validation
- Extended Validation
- Code Signing
- IP Address
If you find any inaccuracies, or you have details to add to these SSL installation instructions, please feel free to send us your feedback at [email protected]. Your input would be greatly appreciated! Thank you.