Installing an SSL Certificate (PFX Format) on a Tomcat Server
By installing an SSL certificate on your Tomcat server, you can enable HTTPS secure access for it. This document describes how to install an SSL certificate on a Tomcat server.
This document uses Tomcat version tomcat9.0.13 as an example.
Before installation, confirm that port 443 is not occupied. If port 443 is already in use, bind another port when installing the certificate.
Obtain the Certificate
- After we issue the certificate for you, we will provide the certificate file in .zip compressed format. The archive contains four folders corresponding to four certificate formats: Tomcat, Nginx, IIS, and Apache. Since this document uses the PFX format for installation, you need to use the certificate in the IIS folder. (The files in different folders only differ in format; using files from other folders does not cause conflicts.)
- The IIS folder contains three files:
domain_com.pfxcertificate filedomain_com.keyprivate key filepassword.txtcertificate password file
Install the SSL Certificate
- Copy the obtained
domain_com.pfxcertificate file from your local directory to the/usr/tomcat9.0.13/confdirectory on the Tomcat server. The path name may vary slightly between different Tomcat versions; please navigate to the corresponding path for your service to perform the operation. - Edit the
server.xmlfile located in the/usr/tomcat9.0.13/confdirectory. Add theConnectorattribute to theserver.xmlfile with the following content:
<Connector port="443"
protocol="HTTP/1.1"
SSLEnabled="true"
scheme="https"
secure="true"
keystoreFile="/usr/tomcat9.0.13/conf/domain_com.pfx" <! -- Path to the certificate -->
keystoreType="PKCS12"
keystorePass="Certificate password" <! -- Replace with the content from the password.txt file -->
clientAuth="false"
SSLProtocol="TLSv1.1+TLSv1.2+TLSv1.3"
ciphers="TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256"/>
- Save the configuration file and run the following command in the
bindirectory to verify if the configuration is correct.
./configtest.sh
- Restart Tomcat, and execute the following command in the
bindirectory:
./shutdown.sh #关闭 Tomcat 服务器
./startup.sh #启动 Tomcat 服务器
Test the SSL Certificate
Enter the domain name bound to the SSL certificate in the browser address bar to test whether your SSL certificate is installed successfully. If successful, a security padlock icon will appear in the browser address bar, and you can click it to view certificate information.

Security Configuration for Automatic HTTP to HTTPS Redirection (Optional)
If you need to automatically redirect HTTP requests to HTTPS, you can configure it by following the steps below:
- Edit the
web.xmlfile in the/usr/tomcat9.0.13/confdirectory and locate the</welcome-file-list>tag. - Add a new line after the closing tag
</welcome-file-list>and insert the following content.
<login-config>
<!-- Authorization setting for SSL -->
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<security-constraint>
<!-- Authorization setting for SSL -->
<web-resource-collection >
<web-resource-name >SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
- Edit the
server.xmlfile under the/usr/tomcat9.0.13/confdirectory, and change theredirectPortparameter to the SSL port forconnector, which is port 443, as shown below:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
- Save the configuration file, and run the following command in the
bindirectory to verify that the configuration is correct.
./configtest.sh
- If the configuration is correct, restart the Tomcat server to access your website via the domain name, and enable automatic redirection from HTTP to HTTPS.
./shutdown.sh #关闭 Tomcat 服务器
./startup.sh #启动 Tomcat 服务器