jetty-ssl.xml文件配置

jetty.ssl文件

注意:xml头部文件http://www.eclipse.org/jetty/configure.dtd用来对该文档格式进行描述,测试该文档是否为有效的XML文档。由于dtd是从http://www.eclipse.org/jetty/configure.dtd上下载下来的,如果网络不好会导致文件下不下来,启动项目可能引起dtd文件not found 的错误,这样便无法解析jetty-ssl.xml文件导致项目启动不了。












<Configure id="Server" class="org.eclipse.jetty.server.Server">

  

  <New id="sslContextFactory" class="org.eclipse.jetty.http.ssl.SslContextFactory">
    
    <Set name="KeyStore"><Property name="jetty.home" default="." />src/main/resources/conf/server.keystoreSet>
    
    <Set name="KeyStorePassword">KeyStore的密码Set>
    
    <Set name="KeyManagerPassword">KeyPair的密码Set>
    
    <Set name="TrustStore"><Property name="jetty.home" default="." />src/main/resources/conf/server.keystoreSet>
    
    <Set name="TrustStorePassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4Set>
  New>

  <Call name="addConnector">
    <Arg>
      <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
        <Arg><Ref refid="sslContextFactory" />Arg>
        <Set name="Port">8443Set>
        <Set name="maxIdleTime">30000Set>
        <Set name="Acceptors">2Set>
        <Set name="AcceptQueueSize">100Set>
      New>
    Arg>
  Call>
Configure>

下载portecle-1.7 http://download.csdn.net/download/haleyliu123/9981504
jetty-ssl.xml文件配置_第1张图片
双击portecle.jar
jetty-ssl.xml文件配置_第2张图片

如果要试验继续进行,我们还需要证书。那怎么生成证书呢?我这里推荐一款pfx加密证书神器,链接:http://download.csdn.net/download/haleyliu123/9981908

jetty-ssl.xml文件配置_第3张图片
jetty-ssl.xml文件配置_第4张图片

jetty-ssl.xml文件配置_第5张图片
这样在output目录下就生成了证书:
jetty-ssl.xml文件配置_第6张图片

然后就是用portecle生成keystore
jetty-ssl.xml文件配置_第7张图片
jetty-ssl.xml文件配置_第8张图片
jetty-ssl.xml文件配置_第9张图片
jetty-ssl.xml文件配置_第10张图片
jetty-ssl.xml文件配置_第11张图片
jetty-ssl.xml文件配置_第12张图片

jetty-ssl.xml文件配置_第13张图片

最后一步:
1.把keystore文件复制到jetty的etc文件夹去

2.配置jetty-ssl.xml文件

配置3个地方,一个是指定keystore文件路径,第二个是设置keystore的密码,第三个是设置keystore里面keypair的密码

jetty-ssl.xml文件配置_第14张图片

3.激活jetty-ssl.xml文件

在jetty的根目录下找到start.ini文件,把 “etc/jetty-ssl.xml”前面的#给去掉
jetty-ssl.xml文件配置_第15张图片

你可能感兴趣的:(【Java】)