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:
Run the server from within your web application directory with
(you might have to run mvn clean install before that).
- 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.