Java 如何将https/ssl与Maven/Mortbay Jetty插件一起使用?

Java 如何将https/ssl与Maven/Mortbay Jetty插件一起使用?,java,maven-2,ssl,https,jetty,Java,Maven 2,Ssl,Https,Jetty,我想使用ssl/https,如中所述 使用jetty maven插件,但我不知道如何配置插件。有任何提示、示例、教程、演练吗 此外,我想知道如何执行上述教程的步骤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

我想使用ssl/https,如中所述

使用jetty maven插件,但我不知道如何配置插件。有任何提示、示例、教程、演练吗


此外,我想知道如何执行上述教程的步骤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
).

您可以使用Maven创建开发证书,并在启动Jetty时使用它。首先,配置keytool maven插件以创建开发证书:

<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>
<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>

org.codehaus.mojo

.

如果使用Pascal的解决方案出现此错误:-

Could not find goal 'genkey' in plugin org.codehaus.mojo:keytool-maven-plugin:1.3
  • 使用“generateKeyPair”作为目标。(我认为genKey不受欢迎。)
  • 添加插件版本
  • 插件定义应该如下所示:-

           <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><!-- put your CN here -->
                    <keypass>jetty6</keypass>
                    <storepass>jetty6</storepass>
                    <alias>jetty6</alias>
                    <keyalg>RSA</keyalg>
                </configuration>
            </plugin>
    
    
    org.codehaus.mojo
    keytool maven插件
    1.3
    产生资源
    清洁的
    清洁的
    产生资源
    根基
    发电机对
    ${project.build.directory}/jetty-ssl.keystore
    cn=my.hostname.tld
    码头6
    码头6
    码头6
    RSA
    
    如果您想使用Jetty 9执行此操作,请注意,由于Jetty-9.0不再能够在pom.xml中直接配置https连接器:您需要使用Jetty xml配置文件来执行此操作

    以下是一个例子:

    pom.xml

    <properties>
    <jetty-version>9.1.2.v20140210</jetty-version>
    </properties>
    ...
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
      <version>${jetty-version}</version>
    </dependency>
    ...
          <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=127.0.0.1</dname><!-- put your CN here -->
                    <keypass>dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g</keypass>
                    <storepass>dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g</storepass>
                    <alias>jetty</alias>
                    <keyalg>RSA</keyalg>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty-version}</version>
                <configuration>
                    <jettyXml>src/main/resources/jetty.xml,src/main/resources/jetty-ssl.xml,src/main/resources/jetty-https.xml</jettyXml>
                </configuration>
            </plugin>    
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    <Configure id="Server" class="org.eclipse.jetty.server.Server">
      <Call id="httpsConnector" name="addConnector">
        <Arg>
          <New class="org.eclipse.jetty.server.ServerConnector">
            <Arg name="server"><Ref refid="Server" /></Arg>
            <Arg name="factories">
              <Array type="org.eclipse.jetty.server.ConnectionFactory">
                <Item>
                  <New class="org.eclipse.jetty.server.SslConnectionFactory">
                    <Arg name="next">http/1.1</Arg>
                    <Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
                  </New>
                </Item>
                <Item>
                  <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                    <Arg name="config"><Ref refid="sslHttpConfig"/></Arg>
                  </New>
                </Item>
              </Array>
            </Arg>
            <Set name="host"><Property name="jetty.host" /></Set>
            <Set name="port"><Property name="jetty.https.port" default="8443" /></Set>
            <Set name="idleTimeout">30000</Set>
          </New>
        </Arg>
      </Call>
    </Configure>
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    
    <!-- ============================================================= -->
    <!-- Configure a TLS (SSL) Context Factory                         -->
    <!-- This configuration must be used in conjunction with jetty.xml -->
    <!-- and either jetty-https.xml or jetty-spdy.xml (but not both)   -->
    <!-- ============================================================= -->
    <Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
      <Set name="KeyStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.keystore" default="target/jetty-ssl.keystore"/></Set>
      <Set name="KeyStorePassword"><Property name="jetty.keystore.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="KeyManagerPassword"><Property name="jetty.keymanager.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="TrustStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.truststore" default="target/jetty-ssl.keystore"/></Set>
      <Set name="TrustStorePassword"><Property name="jetty.truststore.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="EndpointIdentificationAlgorithm"></Set>
      <Set name="ExcludeCipherSuites">
        <Array type="String">
          <Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
          <Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
        </Array>
      </Set>
    
      <!-- =========================================================== -->
      <!-- Create a TLS specific HttpConfiguration based on the        -->
      <!-- common HttpConfiguration defined in jetty.xml               -->
      <!-- Add a SecureRequestCustomizer to extract certificate and    -->
      <!-- session information                                         -->
      <!-- =========================================================== -->
      <New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
        <Arg><Ref refid="httpConfig"/></Arg>
        <Call name="addCustomizer">
          <Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
        </Call>
      </New>
    
    </Configure>
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
    <Configure id="Server" class="org.eclipse.jetty.server.Server">
     <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
     <Set name="secureScheme">https</Set>
     <Set name="securePort">
      <Property name="jetty.secure.port" default="8443" />
     </Set>
     </New>
    </Configure>
    
    
    9.1.2.v20140210
    ...
    org.eclipse.jetty
    jetty服务器
    ${jetty版本}
    ...
    org.codehaus.mojo
    keytool maven插件
    1.3
    产生资源
    清洁的
    清洁的
    产生资源
    根基
    发电机对
    ${project.build.directory}/jetty-ssl.keystore
    cn=127.0.0.1
    dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g
    dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g
    码头
    RSA
    org.eclipse.jetty
    jetty maven插件
    ${jetty版本}
    src/main/resources/jetty.xml、src/main/resources/jetty ssl.xml、src/main/resources/jetty-https.xml
    
    jetty https.xml

    <properties>
    <jetty-version>9.1.2.v20140210</jetty-version>
    </properties>
    ...
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
      <version>${jetty-version}</version>
    </dependency>
    ...
          <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=127.0.0.1</dname><!-- put your CN here -->
                    <keypass>dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g</keypass>
                    <storepass>dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g</storepass>
                    <alias>jetty</alias>
                    <keyalg>RSA</keyalg>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty-version}</version>
                <configuration>
                    <jettyXml>src/main/resources/jetty.xml,src/main/resources/jetty-ssl.xml,src/main/resources/jetty-https.xml</jettyXml>
                </configuration>
            </plugin>    
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    <Configure id="Server" class="org.eclipse.jetty.server.Server">
      <Call id="httpsConnector" name="addConnector">
        <Arg>
          <New class="org.eclipse.jetty.server.ServerConnector">
            <Arg name="server"><Ref refid="Server" /></Arg>
            <Arg name="factories">
              <Array type="org.eclipse.jetty.server.ConnectionFactory">
                <Item>
                  <New class="org.eclipse.jetty.server.SslConnectionFactory">
                    <Arg name="next">http/1.1</Arg>
                    <Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
                  </New>
                </Item>
                <Item>
                  <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                    <Arg name="config"><Ref refid="sslHttpConfig"/></Arg>
                  </New>
                </Item>
              </Array>
            </Arg>
            <Set name="host"><Property name="jetty.host" /></Set>
            <Set name="port"><Property name="jetty.https.port" default="8443" /></Set>
            <Set name="idleTimeout">30000</Set>
          </New>
        </Arg>
      </Call>
    </Configure>
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    
    <!-- ============================================================= -->
    <!-- Configure a TLS (SSL) Context Factory                         -->
    <!-- This configuration must be used in conjunction with jetty.xml -->
    <!-- and either jetty-https.xml or jetty-spdy.xml (but not both)   -->
    <!-- ============================================================= -->
    <Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
      <Set name="KeyStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.keystore" default="target/jetty-ssl.keystore"/></Set>
      <Set name="KeyStorePassword"><Property name="jetty.keystore.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="KeyManagerPassword"><Property name="jetty.keymanager.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="TrustStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.truststore" default="target/jetty-ssl.keystore"/></Set>
      <Set name="TrustStorePassword"><Property name="jetty.truststore.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="EndpointIdentificationAlgorithm"></Set>
      <Set name="ExcludeCipherSuites">
        <Array type="String">
          <Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
          <Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
        </Array>
      </Set>
    
      <!-- =========================================================== -->
      <!-- Create a TLS specific HttpConfiguration based on the        -->
      <!-- common HttpConfiguration defined in jetty.xml               -->
      <!-- Add a SecureRequestCustomizer to extract certificate and    -->
      <!-- session information                                         -->
      <!-- =========================================================== -->
      <New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
        <Arg><Ref refid="httpConfig"/></Arg>
        <Call name="addCustomizer">
          <Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
        </Call>
      </New>
    
    </Configure>
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
    <Configure id="Server" class="org.eclipse.jetty.server.Server">
     <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
     <Set name="secureScheme">https</Set>
     <Set name="securePort">
      <Property name="jetty.secure.port" default="8443" />
     </Set>
     </New>
    </Configure>
    
    
    http/1.1
    30000
    
    jetty ssl.xml

    <properties>
    <jetty-version>9.1.2.v20140210</jetty-version>
    </properties>
    ...
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
      <version>${jetty-version}</version>
    </dependency>
    ...
          <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=127.0.0.1</dname><!-- put your CN here -->
                    <keypass>dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g</keypass>
                    <storepass>dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g</storepass>
                    <alias>jetty</alias>
                    <keyalg>RSA</keyalg>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty-version}</version>
                <configuration>
                    <jettyXml>src/main/resources/jetty.xml,src/main/resources/jetty-ssl.xml,src/main/resources/jetty-https.xml</jettyXml>
                </configuration>
            </plugin>    
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    <Configure id="Server" class="org.eclipse.jetty.server.Server">
      <Call id="httpsConnector" name="addConnector">
        <Arg>
          <New class="org.eclipse.jetty.server.ServerConnector">
            <Arg name="server"><Ref refid="Server" /></Arg>
            <Arg name="factories">
              <Array type="org.eclipse.jetty.server.ConnectionFactory">
                <Item>
                  <New class="org.eclipse.jetty.server.SslConnectionFactory">
                    <Arg name="next">http/1.1</Arg>
                    <Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
                  </New>
                </Item>
                <Item>
                  <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                    <Arg name="config"><Ref refid="sslHttpConfig"/></Arg>
                  </New>
                </Item>
              </Array>
            </Arg>
            <Set name="host"><Property name="jetty.host" /></Set>
            <Set name="port"><Property name="jetty.https.port" default="8443" /></Set>
            <Set name="idleTimeout">30000</Set>
          </New>
        </Arg>
      </Call>
    </Configure>
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    
    <!-- ============================================================= -->
    <!-- Configure a TLS (SSL) Context Factory                         -->
    <!-- This configuration must be used in conjunction with jetty.xml -->
    <!-- and either jetty-https.xml or jetty-spdy.xml (but not both)   -->
    <!-- ============================================================= -->
    <Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
      <Set name="KeyStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.keystore" default="target/jetty-ssl.keystore"/></Set>
      <Set name="KeyStorePassword"><Property name="jetty.keystore.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="KeyManagerPassword"><Property name="jetty.keymanager.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="TrustStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.truststore" default="target/jetty-ssl.keystore"/></Set>
      <Set name="TrustStorePassword"><Property name="jetty.truststore.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="EndpointIdentificationAlgorithm"></Set>
      <Set name="ExcludeCipherSuites">
        <Array type="String">
          <Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
          <Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
        </Array>
      </Set>
    
      <!-- =========================================================== -->
      <!-- Create a TLS specific HttpConfiguration based on the        -->
      <!-- common HttpConfiguration defined in jetty.xml               -->
      <!-- Add a SecureRequestCustomizer to extract certificate and    -->
      <!-- session information                                         -->
      <!-- =========================================================== -->
      <New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
        <Arg><Ref refid="httpConfig"/></Arg>
        <Call name="addCustomizer">
          <Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
        </Call>
      </New>
    
    </Configure>
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
    <Configure id="Server" class="org.eclipse.jetty.server.Server">
     <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
     <Set name="secureScheme">https</Set>
     <Set name="securePort">
      <Property name="jetty.secure.port" default="8443" />
     </Set>
     </New>
    </Configure>
    
    
    /
    /
    SSL_RSA_与_DES_CBC_SHA
    SSL\U DHE\U RSA\U导出\U DES40\U CBC\U SHA
    
    jetty.xml

    <properties>
    <jetty-version>9.1.2.v20140210</jetty-version>
    </properties>
    ...
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
      <version>${jetty-version}</version>
    </dependency>
    ...
          <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=127.0.0.1</dname><!-- put your CN here -->
                    <keypass>dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g</keypass>
                    <storepass>dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g</storepass>
                    <alias>jetty</alias>
                    <keyalg>RSA</keyalg>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty-version}</version>
                <configuration>
                    <jettyXml>src/main/resources/jetty.xml,src/main/resources/jetty-ssl.xml,src/main/resources/jetty-https.xml</jettyXml>
                </configuration>
            </plugin>    
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    <Configure id="Server" class="org.eclipse.jetty.server.Server">
      <Call id="httpsConnector" name="addConnector">
        <Arg>
          <New class="org.eclipse.jetty.server.ServerConnector">
            <Arg name="server"><Ref refid="Server" /></Arg>
            <Arg name="factories">
              <Array type="org.eclipse.jetty.server.ConnectionFactory">
                <Item>
                  <New class="org.eclipse.jetty.server.SslConnectionFactory">
                    <Arg name="next">http/1.1</Arg>
                    <Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
                  </New>
                </Item>
                <Item>
                  <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                    <Arg name="config"><Ref refid="sslHttpConfig"/></Arg>
                  </New>
                </Item>
              </Array>
            </Arg>
            <Set name="host"><Property name="jetty.host" /></Set>
            <Set name="port"><Property name="jetty.https.port" default="8443" /></Set>
            <Set name="idleTimeout">30000</Set>
          </New>
        </Arg>
      </Call>
    </Configure>
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    
    <!-- ============================================================= -->
    <!-- Configure a TLS (SSL) Context Factory                         -->
    <!-- This configuration must be used in conjunction with jetty.xml -->
    <!-- and either jetty-https.xml or jetty-spdy.xml (but not both)   -->
    <!-- ============================================================= -->
    <Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
      <Set name="KeyStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.keystore" default="target/jetty-ssl.keystore"/></Set>
      <Set name="KeyStorePassword"><Property name="jetty.keystore.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="KeyManagerPassword"><Property name="jetty.keymanager.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="TrustStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.truststore" default="target/jetty-ssl.keystore"/></Set>
      <Set name="TrustStorePassword"><Property name="jetty.truststore.password" default="dypBdX1NB3gXA0DXCy9nfyJ4jqUDlaydgbo9OU12g"/></Set>
      <Set name="EndpointIdentificationAlgorithm"></Set>
      <Set name="ExcludeCipherSuites">
        <Array type="String">
          <Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
          <Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
        </Array>
      </Set>
    
      <!-- =========================================================== -->
      <!-- Create a TLS specific HttpConfiguration based on the        -->
      <!-- common HttpConfiguration defined in jetty.xml               -->
      <!-- Add a SecureRequestCustomizer to extract certificate and    -->
      <!-- session information                                         -->
      <!-- =========================================================== -->
      <New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
        <Arg><Ref refid="httpConfig"/></Arg>
        <Call name="addCustomizer">
          <Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
        </Call>
      </New>
    
    </Configure>
    
    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
    <Configure id="Server" class="org.eclipse.jetty.server.Server">
     <New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
     <Set name="secureScheme">https</Set>
     <Set name="securePort">
      <Property name="jetty.secure.port" default="8443" />
     </Set>
     </New>
    </Configure>
    
    
    https
    
    Pascal,你真是个奇迹。。。又一次,太多了+回答得很好!您认为这些Jetty配置也可以与使用Jetty的cargo插件一起使用吗?@PascalThivent:您认为您可以用最新版本的
    keytool maven插件
    和Eclipse版本的
    Jetty maven插件
    来说明上述情况吗?与提出此问题时相比,它们都有重大变化。我已在此处打开了一个新的SO:。非常感谢!这非常接近,但我得到:[错误]1)org.codehaus.mojo.keytool.keytool CommandLineBuilder没有绑定任何实现。[错误]在查找org.codehaus.mojo.keytool.DefaultKeyTool时-有什么想法吗?像往常一样,我回答自己的问题。keytool maven plugin->1.5版而不是1.3版我在Jetty 9中找到的唯一有效、清晰的步骤是: