0

I'm trying to configure SSL on Jetty 9.0.4. I'm using Jetty with WebSockets, and Autobahn Android for the Client.

I tried several configurations, following this: http://www.eclipse.org/jetty/documentation/current/configuring-ssl.html

And this: Configure SSL on Jetty

At the end I always have this exception

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)

I put everything in jetty.xml. Here is my configuration.

<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>

Then all what I did without SSL should work on jetty ? My servlet and socket ?

Thanks everybody

Community
  • 1
  • 1
brunettia
  • 135
  • 4
  • 17

2 Answers2

1

Actually, I was on Jetty 9.0.3 using the librairies of version 9.0.4. I upgraded the server to 9.0.4 and it now works!

brunettia
  • 135
  • 4
  • 17
1

I had the same problem (on jetty 9.0.4). With all libs of the 9.0.4 versions, and the error presumed.

After some digging in examples; I encountered this jetty configuration example. When you look at the jetty-ssl.xml file you encounter following code:

    <!-- =========================================================== -->
  <!-- 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>

When you add this to you xml file all should be working.

jerrevds
  • 173
  • 1
  • 6