【问题标题】:Configuring generated keystore in jetty ssl file在 jetty ssl 文件中配置生成的密钥库
【发布时间】:2018-12-21 04:10:48
【问题描述】:

我必须在 Jetty 中启用 SSL。我使用Keytool 生成了密钥库文件。我已将这个 keytool 文件包含在 JETTY_BASE\etc\myKeystore 中。我在JETTY_BASE\etc 中包含了jetty-https.xmljetty-ssl.xml

码头-https.xml:

<?xml version="1.0"?>
 <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="acceptors" type="int"><Property name="ssl.acceptors" default="-1"/></Arg>
        <Arg name="selectors" type="int"><Property name="ssl.selectors" default="-1"/></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="https.port" default="443" /></Set>
        <Set name="idleTimeout"><Property name="https.timeout" default="30000"/></Set>
        <Set name="soLingerTime"><Property name="jetty.https.soLingerTime" default="-1"/></Set>
        <Set name="acceptorPriorityDelta"><Property name="jetty.https.acceptorPriorityDelta" default="0"/></Set>
        <Set name="acceptQueueSize"><Property name="jetty.https.acceptQueueSize" default="0"/></Set>
      </New>
    </Arg>
  </Call>
</Configure>

jetty-ssl.xml:

<?xml version="1.0"?>
<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
  <Set name="KeyStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.keystore" default=""/>etc/myKeystore</Set>
  <Set name="KeyStorePassword"><Property name="jetty.keystore.password" default=""/>password</Set>
  <Set name="KeyManagerPassword"><Property name="jetty.keymanager.password" default=""/>password</Set>
  <Set name="TrustStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.truststore" default=""/>etc/myKeystore</Set>
  <Set name="TrustStorePassword"><Property name="jetty.truststore.password" default=""/>password</Set>
  <Set name="EndpointIdentificationAlgorithm"></Set>
  <Set name="NeedClientAuth"><Property name="jetty.ssl.needClientAuth" default="false"/></Set>
  <Set name="WantClientAuth"><Property name="jetty.ssl.wantClientAuth" default="false"/></Set>
  <Set name="ExcludeCipherSuites">
    <Array type="String">
      <Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
      <Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
      <Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
      <Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
      <Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
      <Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
      <Item>SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</Item>
    </Array>
  </Set>
  <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>

虽然我已将我的密钥库文件指定为

  <Set name="KeyStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.keystore" default=""/>etc/myKeystore</Set>

无法识别。 Jetty 使用位于 'JETTY_BASE/etc' 中的默认 'keystore' 文件。如何使用生成的密钥库文件?

【问题讨论】:

    标签: ssl jetty jetty-9


    【解决方案1】:

    start.ini 中包含详细信息并删除文件jetty-https.xmljetty-ssl.xml

    样本start.ini:

    ## Keystore file path (relative to $jetty.base)
    jetty.sslContext.keyStorePath=etc/myKeystore
    
    ## Truststore file path (relative to $jetty.base)
    jetty.sslContext.trustStorePath=etc/myKeystore
    
    ## Keystore password
    jetty.sslContext.keyStorePassword=password
    
    ## Keystore type and provider
    # jetty.sslContext.keyStoreType=JKS
    # jetty.sslContext.keyStoreProvider=
    
    ## KeyManager password
    jetty.sslContext.keyManagerPassword=password    
    ## Truststore password
    jetty.sslContext.trustStorePassword=password
    

    来自码头documentation

    不建议同时使用 ${jetty.base}/start.ini 文件和 ${jetty.base}/start.d 目录同时这样做可以 导致问题。

    【讨论】:

      猜你喜欢
      • 2011-06-09
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 2018-11-29
      • 2019-11-25
      • 1970-01-01
      • 2015-09-13
      相关资源
      最近更新 更多