Tomcat uses a proprietary key format "JKS" (Java Key Store).
Certificate (public key), certification chain (if available) and a private key are converted to JKS in the following way:
1. Convert the key and the certificates into the PKCS12 format
openssl pkcs12 -export -out server.p12 -inkey domain.com.key -in ServerCertificate.cer -certfile CAchain.crt
Important! The certificate chain of authority centers must be entered, otherwise you may get a "Trust anchor for certification path not found" error!
The certificate chain is created by concatenation of all available certificates into one file:
cat CACertificate-ROOT-2.cer CACertificate-INTERMEDIATE-1.cer > CAchain.crt
Important! After running this command, view the CAchain.crt file and make sure the certificate boundaries didn't concatenate: each boundary should be on its own line!
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
2. Convert PKCS12 into JKS
keytool -importkeystore -destkeystore server.jks -srckeystore server.p12 -srcstoretype PKCS12
Here the passwords for source and destination keystore must be entered.
3. Add path to the JKS file and password to the Tomcat settings (/etc/tomcat9/server.xml):
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" defaultSSLHostConfigName="your-domain.com">
<SSLHostConfig hostName="your-domain.com">
<Certificate certificateKeystoreFile="/var/lib/tomcat9/ssl/server.jks" type="RSA" certificateKeystorePassword="******" />
</SSLHostConfig>
</Connector>
4. Change the URL in the Headwind MDM configuration file (ROOT.xml or hmdm.xml) from HTTP to HTTPS
<Parameter name="base.url" value="https://your-domain.com"/>
5. Restart tomcat
service tomcat9 restart
6. Forward the port 443 to 8443, also for the local network interface (here's why):
/sbin/iptables -A PREROUTING -t nat -i eno1 -p tcp -m tcp -d your-domain.com --dport 443 -j REDIRECT --to-ports 8443
/sbin/iptables -A OUTPUT -t nat -o lo -p tcp -m tcp -d your-domain.com --dport 443 -j REDIRECT --to-ports 8443
7. Check that the iptables setup is restored after reboot. Make iptables settings permanent if required.