Search code examples
javassltomcat7jks

How to specify keystore location for Tomcat7 WAR?


I have a custom JKS file (keystore) on my file system under /opt/myapp/keystore/myapp.jks and am deploying a myapp.war to Tomcat7 that needs to use it.

If this was an executable JAR (and not a WAR), I might do something like:

java -jar myapp.jar -Djavax.net.ssl.keyStore=/opt/myapp/keystore/myapp.jks
    -Djavax.net.ssl/keyStorePassword=mypasswd

How/where do I accomplish the same in Tomcat7?


Solution

  • You can add an SSL connector to the conf/server.xml file as the example below:

    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
                   maxThreads="150" scheme="https" secure="true"
                   keyAlias="your-cert-key" keystoreFile="your-keystore-path.keystore" 
                   keystorePass="yourpassword"
                   clientAuth="false" sslProtocol="TLS" />