如何在 Maven/Mortbay Jetty 插件中使用 https/ssl? [英] HowTo use https / ssl with Maven/Mortbay Jetty Plugin?

查看:33
本文介绍了如何在 Maven/Mortbay Jetty 插件中使用 https/ssl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 ssl/https,如

I would like to use ssl / https as described in

http://docs.codehaus.org/display/JETTY/How+to+configure+SSL

使用jetty-maven-plugin,但是不知道怎么配置插件.任何提示、示例、教程、演练?

using jetty-maven-plugin, but I don't know how to configure the plugin. Any hint, example, tutorial, walkthrough ?

另外,我想知道如何执行上述教程的第 3b 步,其中需要操作 jetty 服务器(java -classpath $JETTY_HOME/lib/jetty-util-6.1-SNAPSHOT.jar:$JETTY_HOME/lib/jetty-6.1-SNAPSHOT.jar org.mortbay.jetty.security.PKCS12Import jetty.pkcs12 keystore).

Also, I wonder how to carry out Step 3b of the above mentioned tutorial, where manipulation the jetty server is necessary (java -classpath $JETTY_HOME/lib/jetty-util-6.1-SNAPSHOT.jar:$JETTY_HOME/lib/jetty-6.1-SNAPSHOT.jar org.mortbay.jetty.security.PKCS12Import jetty.pkcs12 keystore).

推荐答案

可以使用 Maven 创建开发证书并在启动 Jetty 时使用.首先,配置keytool-maven-plugin来创建开发证书:

You can use Maven to create a development certificate and use it when starting Jetty. First, configure the keytool-maven-plugin to create a development certificate:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>keytool-maven-plugin</artifactId>
  <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>genkey</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <keystore>${project.build.directory}/jetty-ssl.keystore</keystore>
    <dname>cn=my.hostname.tld</dname><!-- put your CN here-->
    <keypass>jetty6</keypass>
    <storepass>jetty6</storepass>
    <alias>jetty6</alias>
    <keyalg>RSA</keyalg>
  </configuration>
</plugin>

根据需要更改 CN.然后配置maven-jetty-plugin使用开发证书:

Change the CN as you wish. Then configure the maven-jetty-plugin to use the development certificate:

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty-plugin</artifactId>
  <version>6.1.10</version>
  <configuration>
    <contextPath>/context</contextPath>
    <scanIntervalSeconds>5</scanIntervalSeconds>
    <connectors>
      <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
        <port>8080</port>
        <maxIdleTime>60000</maxIdleTime>
      </connector>
      <connector implementation="org.mortbay.jetty.security.SslSocketConnector">
        <port>8443</port>
        <maxIdleTime>60000</maxIdleTime>
        <keystore>${project.build.directory}/jetty-ssl.keystore</keystore>
        <password>jetty6</password>
        <keyPassword>jetty6</keyPassword>
      </connector>
    </connectors>
  </configuration>
</plugin>

运行 mvn jetty:run 并打开 https://localhost:8443/context.

这篇关于如何在 Maven/Mortbay Jetty 插件中使用 https/ssl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆