Use the PFX directly
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
SSLEnabled="true" maxThreads="150">
<SSLHostConfig protocols="TLSv1.2+TLSv1.3">
<Certificate certificateKeystoreFile="conf/server.pfx"
certificateKeystoreType="PKCS12"
certificateKeystorePassword="password-from-export" />
</SSLHostConfig>
</Connector>
Without certificateKeyAlias, Tomcat takes the first key in the file. That almost always works, because a PFX holds only one key.
What is in the file?
keytool -list -v -keystore server.pfx -storetype PKCS12 | grep -E "Alias|Entry type|chain length"
- Alias: with exports from Windows this is often a long GUID or the friendly name. If you need it, put exactly this value into
certificateKeyAlias. - Entry type: PrivateKeyEntry must be there. If it only says
trustedCertEntry, the private key is missing; the export from Windows was done without the key. - Certificate chain length should be 2 or 3. With 1, the intermediates are missing.
It is easier in the certificate converter or the Java keystore helper: drop the file in, enter the password, view the contents.
Export correctly from Windows
- Open
certlm.msc, select the certificate under Personal → Certificates, right-click → All Tasks → Export. - Choose “Yes, export the private key”. If the option is greyed out, the key was created as non-exportable. Then only a new certificate helps.
- Tick “Include all certificates in the certification path if possible”. That puts the intermediates in the file.
- Set a password. For encryption, “TripleDES-SHA1” works everywhere. “AES256-SHA256” is more modern, but very old Java 8 versions cannot read it.
Complete a missing chain
If the intermediates are missing, repackage the PFX with OpenSSL:
openssl pkcs12 -in server.pfx -nodes -out all.pem # add -legacy if needed openssl pkcs12 -export -in all.pem -certfile intermediate.crt \ -name tomcat -out server-new.p12
Or without a command line: the certificate converter adds the intermediates automatically and saves a new PFX.
Typical error messages
keystore password was incorrect: wrong password. Escape special characters in server.xml:&for &,<for <.Invalid keystore format:certificateKeystoreType="PKCS12"is missing and Tomcat reads the file as JKS.DerInputStream.getLength(): lengthTag=…: the file is not a PFX at all but PEM (text with-----BEGIN). UsecertificateFileandcertificateKeyFileor convert it, see convert PFX and PEM.Alias name … does not identify a key entry: wrong alias incertificateKeyAlias.
How keystores work in Tomcat in general is in the article configure a keystore in Tomcat.
FAQ
Do I have to convert the PFX to JKS?
No. Tomcat reads PKCS#12 directly; since Java 9 it is even the default format.
Can I use the same PFX for IIS and Tomcat?
Yes, if the name in the certificate matches. Both read the same format.
OpenSSL says “unsupported” when opening the PFX.
Older Windows exports use RC2 encryption, which OpenSSL 3 only reads with -legacy. Tomcat or Java can usually open the file anyway.