How to setup SSL with Eclipse's maven-jetty-plugin?
Asked Answered
E

2

3

I would like to be able to launch Jetty with SSL using the latest Eclipse maven-jetty-plugin and the keytool-maven-plugin as seen here. However, those two plugins are now quite outdated.

Could somebody please illustrate a working example of this using the latest versions of the plugins? Thanks!

Encrinite answered 17/2, 2014 at 15:16 Comment(0)
D
0

These two plugin definitions should do it :-

<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.26</version>
            <configuration>
                <jvmArgs>-Xmx2048m -Xms1536m -XX:PermSize=128m -XX:MaxPermSize=256m</jvmArgs>
                <!-- http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin -->
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <connectors>
                    <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                        <port>80</port>
                        <maxIdleTime>60000</maxIdleTime>
                    </connector>
                    <connector implementation="org.mortbay.jetty.security.SslSocketConnector">
                        <port>443</port>
                        <maxIdleTime>60000</maxIdleTime>
                        <keystore>${project.build.directory}/jetty-ssl.keystore</keystore>
                        <password>jetty6</password>
                        <keyPassword>jetty6</keyPassword>
                    </connector>
                </connectors>
                <contextPath>/</contextPath>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>keytool-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <phase>generate-resources</phase>
                    <id>clean</id>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
                <execution>
                    <phase>generate-resources</phase>
                    <id>genkey</id>
                    <goals>
                        <goal>generateKeyPair</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <keystore>${project.build.directory}/jetty-ssl.keystore</keystore>
                <dname>cn=my.hostname.tld</dname>
                <keypass>jetty6</keypass>
                <storepass>jetty6</storepass>
                <alias>jetty6</alias>
                <keyalg>RSA</keyalg>
            </configuration>
        </plugin>
Discomfortable answered 15/5, 2014 at 4:57 Comment(2)
I've seen this reply already on Stackoverflow. It's for a rather old version of Jetty. Both plugins you're mentioning have much newer versions for which the configuration is a lot different, hence my asking. If you could update your reply accordingly, that would be great.Encrinite
Yeah, would love to see a version of this for org.eclipse.jetty/jetty-maven-plugin !Algor
P
0

Carlspring, the trick is the implementation of the SSL connector: package and class name are modified after updates.

At version 6.1.x, the implementation was: org.mortbay.jetty.security.SslSocketConnector

After 8.x, is: org.eclipse.jetty.server.ssl.SslSocketConnector

Note that is also needed to include jetty-ssl dependency in your pom.xml.

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>7.0.0.pre5</version>
  <configuration>
    <connectors>
      <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
        <port>8080</port>
      </connector>
      <connector implementation="org.eclipse.jetty.server.ssl.SslSocketConnector">
        <port>8443</port>
        <keystore>src/test/resources/server.keystore</keystore>
        <keyPassword>123456</keyPassword>
        <password>123456</password>
      </connector>
    </connectors>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty-ssl</artifactId>
      <version>7.0.0.pre5</version>
    </dependency>
  </dependencies>
</plugin>
Pretension answered 9/12, 2016 at 15:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.