In my last post I showed you how to setup a basic execution environment based on Maven and Cargo with a Tomcat 8.x application server; I recommend to read that post if you need an introduction. This article will extend the previous configuration in a way that you can run your web application with a self-signed certificate using the HTTPS protocol in a development / test environment - production of course needs a “real” certificate. Some products or features you need to integrate with your application might require the use of the HTTPS protocol or otherwise will refuse to work for security reasons.

Make use of the Keytool Maven Plugin

One of the key advantages of the approach shown here is that there is no need messing around with command line tools to create fake certificates and manipulate your current Java installation with them. It’s enough to just run Cargo with the Keytool configuration, everything regarding certificates will be handled automatically!

To reach this goal, we integrate the Keytool Maven Plugin with the Maven configuration / pom.xml of our webapp.

Sample Maven configuration with Keytool and Cargo plugins

I have added the needed configuration to the very basic pom.xml of a Magnolia webapp module:

<?xml version="1.0" encoding="UTF-8"?>
  <project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
    <name>magnolia-cargo-demo: webapp</name>
            <!-- exclude jars copied "physically" from the webapp overlay - so we only get those resolved by Maven's dependency management -->
              <!-- Keytool Maven plugin configuration starts here -->
        <!-- end of Keytool Maven Plugin configuration -->

        <!-- Cargo with Tomcat 8 starts here -->
              <!-- -->
              <!-- Instead of downloading the container, you can also reuse an existing installation by settings its directory:
              <home>/Users/horsti/files/tomcats/apache-tomcat-8.5.4</home> -->
              <output>${}/tomcat8x/container.log</output><!-- If true, then the file specified by <output> will not be erased across different runs -->
              <!-- set this value if your web app is taking some time to start -->
                <cargo.jvmargs>-XX:MaxPermSize=512m -Xms256m -Xmx3072m -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -XX:+DisableExplicitGC -Xverify:none -Djava.awt.headless=true</cargo.jvmargs>
                <!-- https configuration -->
                  <!-- set the context for your web app so the correct configuration is applied -->
        <!-- end of Cargo Maven Plugin configuration -->

Run the server from within your web application directory with

mvn cargo:run

Remark: you might have to run mvn clean install before executing cargo:run.


  • Compared to the previous configuration, the port has been changed from 8080 to 8443 and the protocol has been changed to https.
  • The configuration to integrate the Keystore / SSL settings has been added to the Cargo plugin.
  • As in the previous configuration have a look at the context and timeout parameters.