我正在尝试在Jetty 9.0.4上配置SSL。我正在使用Jetty和WebSockets,并使用Autobahn Android作为客户端。
我尝试了以下几种配置:http://www.eclipse.org/jetty/documentation/current/configuring-ssl.html
这个:在Jetty 上配置SSL
最后我总是有这个例外
2013-07-07 13:36:11.742:WARN:oeji.SelectorManager:qtp1384613607-13-selector-0:
java.lang.NullPointerException
at org.eclipse.jetty.server.HttpConnection.<init>(HttpConnection.java:96)
at org.eclipse.jetty.server.HttpConnectionFactory.newConnection(HttpConnectionFactory.java:61)
at org.eclipse.jetty.server.SslConnectionFactory.newConnection(SslConnectionFactory.java:86)
at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:401)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.createEndPoint(SelectorManager.java:575)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.access$500(SelectorManager.java:318)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector$Accept.run(SelectorManager.java:699)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.runChange(SelectorManager.java:407)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.runChanges(SelectorManager.java:396)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.processChanges(SelectorManager.java:479)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:440)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.run(SelectorManager.java:420)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527)
at java.lang.Thread.run(Thread.java:722)
我把所有东西都放在jetty.xml中。这是我的配置。
<New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
<Set name="KeyStorePath">
<Property name="jetty.home" default="." />/<Property name="jetty.keystore" default="etc/keystore"/>
</Set>
<Set name="KeyStorePassword">
<Property name="jetty.keystore.password" default="OBF:password"/>
</Set>
<Set name="KeyManagerPassword">
<Property name="jetty.keymanager.password" default="OBF:password"/>
</Set>
<Set name="TrustStorePath">
<Property name="jetty.home" default="." />/<Property name="jetty.truststore" default="etc/keystore"/>
</Set>
<Set name="TrustStorePassword">
<Property name="jetty.truststore.password" default="OBF:password"/>
</Set>
<Set name="EndpointIdentificationAlgorithm"/>
<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="sslConnector" 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="tlsHttpConfig"/>
</Arg>
</New>
</Item>
</Array>
</Arg>
<Set name="host">
<Property name="jetty.host" />
</Set>
<Set name="port">
<Property name="jetty.tls.port" default="8443" />
</Set>
<Set name="idleTimeout">30000</Set>
</New>
</Arg>
</Call>
那么我在没有SSL的情况下所做的一切都应该在码头上工作吗?我的servlet和套接字?
感谢大家
实际上,我在Jetty 9.0.3上使用的是9.0.4版本的库。我将服务器升级到9.0.4,现在可以工作了!
我也遇到了同样的问题(在jetty 9.0.4上)。9.0.4版本的所有库都存在错误。
经过一番实例挖掘;我遇到了这个码头配置示例。当您查看jetty-ssl.xml文件时,您会遇到以下代码:
<!-- =========================================================== -->
<!-- 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>
当您将其添加到xml文件中时,一切都应该正常工作。