栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在Maven / Mortbay Jetty插件中使用https / ssl?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Maven / Mortbay Jetty插件中使用https / ssl?

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

<plugin>  <groupId>org.prehaus.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 以使用开发证书:

<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



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/595583.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号