Close

How to configure Maven Tomcat Plugin to use HTTPS (SSL/TLS)

[Updated: Jan 22, 2018, Created: Jan 22, 2018]

In this tutorial, we will learn how to configure SSL/TLS with tomcat7-maven-plugin.

  • (1)Creating a Keystore

    Follow the step (1) from the last tutorial to generate a self-signed certificate.



  • (2)Configuring tomcat7-maven-plugin to use HTTPS

    We are reusing our last servlet example, with following changes in pom.xml:

     <plugin>
         <groupId>org.apache.tomcat.maven</groupId>
         <artifactId>tomcat7-maven-plugin</artifactId>
         <version>2.2</version>
         <configuration>
             <path>/</path>
             <httpsPort>8443</httpsPort>
             <keystoreFile>C:\my-cert-dir\localhost-rsa.jks</keystoreFile>
             <keystorePass>123456</keystorePass>
         </configuration>
     </plugin>
    


  • (3)Testing

    To try examples, run embedded tomcat (configured in pom.xml of example project below):

    mvn tomcat7:run-war

    Access application at https://localhost:8443/hello

    Note that, chrome shows 'Not secure' warning with self signed certificate. Check out last tutorial's step (3) for more info.



Example Project

Dependencies and Technologies Used:

  • javax.servlet-api 3.1.0 Java Servlet API
  • JDK 1.8
  • Maven 3.3.9

Apache Tomcat SSL/TLS Configuration Test Example Select All Download
  • servlet-hello-world-https
    • src
      • main
        • java
          • com
            • logicbig
              • example

See Also