SSL Configuration on Maven Tomcat Plugin
Asked Answered
A

2

14

I am trying to develop a Wicket app. It's login page must open with SSL. So I did some coding. But I can't find to configure the maven tomcat 7 plugin for SSL. I created keystore file properly.Using keytool -genkey -alias tomcat -keyalg RSA command It's in the in user directory on windows.It's password is password.

This is how I defined tomcat in pom.xml:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0-beta-1</version>
    <executions>
        <execution>
            <id>tomcat-run</id>
            <goals>
                <goal>exec-war-only</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <path>foo</path>
                <!-- optional only if you want to use a preconfigured server.xml file -->
                <serverXml>src/main/tomcatconf/server.xml</serverXml>
                <!-- optional values which can be configurable -->
                <attachArtifactClassifier>
                                    default value is exec-war but you can   customize
                                </attachArtifactClassifier>
                <attachArtifactClassifierType>
                                      default value is jar
                                </attachArtifactClassifierType>
                <httpsPort>8443</httpsPort>
                <keystoreFile>${user.home}/.keystore</keystoreFile>
                <keystorePass>password</keystorePass>
                <protocol>org.apache.coyote.http11.Http11AprProtocol</protocol>
            </configuration>
        </execution>
    </executions>
</plugin>
Acyclic answered 24/7, 2012 at 14:50 Comment(1)
did you find the correct configuration? I am trying to do something similar without success.Sacha
M
22

With this configuration in my pom.xml I get it working:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
        <path>/${project.build.finalName}</path>
        <contextFile>${basedir}/context.xml</contextFile>
        <httpsPort>8443</httpsPort>
        <keystoreFile>${basedir}/certificates/keystore.jks</keystoreFile>
        <keystorePass>password</keystorePass>
    </configuration>
</plugin>
Meridithmeriel answered 11/12, 2012 at 17:33 Comment(3)
Thanks for your answer! When I test it, I will post the resultAcyclic
Works for me. I added automatic ssl key generationTippet
I'll add a common gotcha here in that you need to run tomcat7:run note the tomcat7.Betrothed
C
8

I was able to get it working with:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
        <path>/mycontext</path>
        <port>9090</port>
        <httpsPort>8443</httpsPort>
        <keystorePass>changeit</keystorePass>
    </configuration>
</plugin>

Be sure you create the keystore from the documentation: http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html (it looks like you have that part) and what finally worked for me was to create the keystore (in the default directory) with both passwords as "changeit"... not sure why, but for me this is ok in this case as this is for local development only.

I am running on Windows 7, Maven 3.

Hope this helps.

Cormorant answered 13/1, 2013 at 12:57 Comment(1)
Thanks for your answer! When I test it, I will post the resultAcyclic

© 2022 - 2024 — McMap. All rights reserved.