Install an SSL Certificate on Apache Tomcat
Tomcat terminates TLS itself through a Connector, and a Connector reads a keystore, not a certificate file. Tomcat supports JKS, PKCS11 and PKCS12 keystores, and its SSL how-to is the reference for every step below (Tomcat SSL how-to). That single fact explains most failed Tomcat SSL setups: the certificate is fine, the key is fine, and the Connector is looking in a keystore that does not contain them.
SSL certificate for Tomcat: two architectures, pick one first
| Setup | Who holds the certificate | When it fits |
|---|---|---|
| Tomcat terminates TLS | Tomcat keystore | Tomcat is the front door, port 443 is published |
| Reverse proxy terminates TLS | Nginx, Apache or a load balancer | You already have a proxy, or several apps share a host |
If a proxy sits in front, do not install the certificate in Tomcat at all. The proxy holds it and forwards plain HTTP to Tomcat on localhost. That is simpler to renew and simpler to debug, and it is what most production deployments do.
Build the keystore for a Tomcat SSL certificate
Start from the files your provider gave you: the certificate, the chain and the private key. Build a PKCS12 keystore first, because Java has used PKCS12 as its default keystore type since Java 9 and it is the format that travels well.
openssl pkcs12 -export \
-in fullchain.pem \
-inkey privkey.pem \
-out tomcat.p12 \
-name tomcat \
-passout pass:ChangeMe123
The -name value is the alias, and it matters: it is the name the Connector can reference. Keep it short and remember it.
If you need a JKS file specifically, convert the PKCS12 you just built:
keytool -importkeystore \
-srckeystore tomcat.p12 -srcstoretype PKCS12 \
-srcstorepass ChangeMe123 \
-destkeystore tomcat.jks -deststoretype JKS \
-deststorepass ChangeMe123
Then list the contents to confirm the alias and the chain are both there:
keytool -list -v -keystore tomcat.p12 -storetype PKCS12
You should see one entry with your alias, a certificate chain of two or three certificates, and a validity date you recognise. One entry with no chain means the intermediate is missing and some clients will reject the site.
Configure the Connector
Edit conf/server.xml and add or replace the secure Connector inside the Service element.
<Connector port="8443" SSLEnabled="true"
protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" scheme="https" secure="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/tomcat.p12"
certificateKeystorePassword="ChangeMe123"
certificateKeystoreType="PKCS12" type="RSA" />
</SSLHostConfig>
</Connector>
Put the keystore where the relative path points, usually $CATALINA_BASE/conf/, and make sure the Tomcat user can read it. Restart Tomcat and watch logs/catalina.out: a wrong password, a missing alias or an unreadable file all surface there at startup, which is far easier to debug than a browser error.
Serve HTTPS on 443
Port 8443 works, but nobody types it. Two options: change the Connector port to 443, which requires starting Tomcat as root or granting the capability to bind a low port, or keep 8443 and put a redirect in front. On Linux, the cleaner answer is usually a proxy or an iptables rule rather than running Tomcat as root.
Newer Tomcat releases can also read PEM files directly with certificateFile and certificateKeyFile on the Certificate element. That removes the keystore step entirely, and it is worth checking against the documentation for your exact version before you build one.
Verify from outside
- Point the SSL checker at the hostname and confirm the chain, the SAN list and the expiry date.
- Confirm the protocol version with the TLS checker; a Connector left on old defaults can still offer TLS 1.0 and 1.1, both deprecated in RFC 8996.
- Check that http:// redirects to https:// rather than serving a second copy of the app. The redirect generator writes the block for whichever server is in front.
Getting a certificate for a Tomcat host
Any publicly trusted certificate works. Generate the key pair where you will use it, issue the certificate, and keep the key: free certificates cover the base domain plus www and are issued in the browser. If you are not sure the key and certificate belong together before you build the keystore, run both through the key matcher first, because a mismatch discovered after the restart costs another deploy.
Related reading: generating a private key and CSR, converting PEM to a Java keystore and free SSL on Apache.
Frequently Asked Questions
Does Tomcat need a proxy for HTTPS?
No. A Connector can terminate TLS itself. A proxy is simpler when you already run Nginx or Apache in front, because renewal and configuration stay in one place.
Why does Tomcat use port 8443 in the docs?
That is the default in the sample Connector so an unprivileged user can start it. To serve 443, change the port and let a privileged process start Tomcat or forward the port.
Which keystore format should I use?
PKCS12 unless you have a reason not to. It is an internet standard, works with OpenSSL and keytool, and Java reads it natively.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.