我在OSGi中使用Jetty 9.2.7.v20150116,我必须创建一个Https连接器,但它无法正常工作。我创建了一个包含jetty.xml的片段包,其中包含以下内容:
<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>
<Set name="outputBufferSize">32768</Set>
<Set name="requestHeaderSize">8192</Set>
<Set name="responseHeaderSize">8192</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">false</Set>
<Set name="headerCacheSize">512</Set>
</New>
<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>
<New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
<Set name="KeyStorePath">C:/keystore</Set>
<Set name="KeyStorePassword">password</Set>
<Set name="KeyManagerPassword">password</Set>
<Set name="TrustStorePath">C:/keystore</Set>
<Set name="TrustStorePassword">password</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>
<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="https.port" default="9443" />
</Set>
<Set name="idleTimeout">
<Property name="https.timeout" default="30000" />
</Set>
<Set name="name">httpsConnector</Set>
</New>
</Arg>
</Call>
<Call id="httpConnector" 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.HttpConnectionFactory">
<Arg name="config">
<Ref refid="httpConfig" />
</Arg>
</New>
</Item>
</Array>
</Arg>
<Set name="host">
<Property name="jetty.host" />
</Set>
<Set name="port">
<Property name="jetty.port" default="8282" />
</Set>
<Set name="idleTimeout">
<Property name="http.timeout" default="30000" />
</Set>
<Set name="name">httpConnector</Set>
</New>
</Arg>
</Call>
<Get name="handler">
<Call name="addHandler">
<Arg>
<New class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/static-content</Set>
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="resourceBase">target/logs</Set>
<Set name="directoriesListed">true</Set>
</New>
</Set>
</New>
</Arg>
</Call>
</Get>
我没有得到任何异常,输出包含以下行:
17:19:02.401 [pool-1-thread-1] DEBUG o.e.j.u.component.ContainerLifeCycle - ServerConnector@31c30fbe{null}{0.0.0.0:0} added {org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper@5c079d6,UNMANAGED}
17:19:02.402 [pool-1-thread-1] DEBUG o.e.j.u.component.ContainerLifeCycle - ServerConnector@31c30fbe{null}{0.0.0.0:0} added {qtp1173186476{STOPPED,8<=0<=200,i=0,q=0},AUTO}
17:19:02.403 [pool-1-thread-1] DEBUG o.e.j.u.component.ContainerLifeCycle - ServerConnector@31c30fbe{null}{0.0.0.0:0} added {org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@58716c6e,AUTO}
17:19:02.403 [pool-1-thread-1] DEBUG o.e.j.u.component.ContainerLifeCycle - ServerConnector@31c30fbe{null}{0.0.0.0:0} added {org.eclipse.jetty.io.ArrayByteBufferPool@296d1b9a,POJO}
17:19:02.404 [pool-1-thread-1] DEBUG o.e.j.u.component.ContainerLifeCycle - ServerConnector@31c30fbe{null}{0.0.0.0:0} added {SslConnectionFactory@1757e7bc{SSL-http/1.1},AUTO}
17:19:02.405 [pool-1-thread-1] DEBUG o.e.j.u.component.ContainerLifeCycle - ServerConnector@31c30fbe{SSL-http/1.1}{0.0.0.0:0} added {HttpConnectionFactory@2458f97{HTTP/1.1},AUTO}
17:19:02.407 [pool-1-thread-1] DEBUG o.e.j.u.component.ContainerLifeCycle - ServerConnector@31c30fbe{SSL-http/1.1}{0.0.0.0:0} added {org.eclipse.jetty.server.ServerConnector$ServerConnectorManager@5b9af7a6,MANAGED}
17:19:02.408 [pool-1-thread-1] DEBUG o.eclipse.jetty.xml.XmlConfiguration - XML ServerConnector@31c30fbe{SSL-http/1.1}{0.0.0.0:0}.setHost(null)
17:19:02.412 [pool-1-thread-1] DEBUG o.eclipse.jetty.xml.XmlConfiguration - XML ServerConnector@31c30fbe{SSL-http/1.1}{0.0.0.0:0}.setPort(9443)
17:19:02.413 [pool-1-thread-1] DEBUG o.eclipse.jetty.xml.XmlConfiguration - XML ServerConnector@31c30fbe{SSL-http/1.1}{0.0.0.0:9443}.setIdleTimeout(30000)
17:19:02.413 [pool-1-thread-1] DEBUG o.eclipse.jetty.xml.XmlConfiguration - XML ServerConnector@31c30fbe{SSL-http/1.1}{0.0.0.0:9443}.setName(httpsConnector)
17:19:02.414 [pool-1-thread-1] DEBUG o.eclipse.jetty.xml.XmlConfiguration - XML call addConnector
当我通过netstat -an
检查打开的端口时,未列出https端口9443。我做错了什么?