Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Implementing HTTP 1.1 encrypted connection upgrade

Hi.

Following up on:
http://jetty.4.n6.nabble.com/jetty-users-Jetty-and-Http-1-1-upgrade-header-td4959222.html

I've tried to tell Jetty to use a SslConnection in order to upgrade the
plain http connection to an encrypted connection.
This is what I tried:

-------------------
// send 101 switching protocols
response.setHeader("Upgrade", proto);
response.setHeader("Connection", "Upgrade");
response.sendError(101, "Switching Protocols");
response.flushBuffer();

AbstractHttpConnection httpCon =
AbstractHttpConnection.getCurrentConnection();
// prepare SslConnection
SSLEngine engine = SSLContext.getDefault().createSSLEngine();
engine.setEnableSessionCreation(true);
EndPoint httpEndPoint = httpCon.getEndPoint();
SslConnection connection = new SslConnection(engine, httpEndPoint);
System.out.println(connection.toString());

// exchange connection
request.setAttribute("org.eclipse.jetty.io.Connection", connection);				
-------------------

When this is executed I'm seeing the following NullPointerException in log:
SslConnection@63dc6270 SSL NOT_HANDSHAKING i/o/u=-1/-1/-1 ishut=false
oshut=false {null}
2012-09-27 13:34:33.483:WARN:oeji.nio:handle failed
java.lang.NullPointerException
	at org.eclipse.jetty.io.nio.SslConnection.handle(SslConnection.java:191)
	at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:622)
	at
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
	at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
	at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
	at java.lang.Thread.run(Thread.java:722)

Looking at the mention line in SslConnection:
// handle the delegate connection
AsyncConnection next = (AsyncConnection)_connection.handle();

And indeed _connection is null.
What am I missing?

Setting this "_connection" field could be done with:
connection.getSslEndPoint().setConnection
But which connection should be placed there?



Regards,
Manfred



--
View this message in context: http://jetty.4.n6.nabble.com/Implementing-HTTP-1-1-encrypted-connection-upgrade-tp4959244.html
Sent from the Jetty User mailing list archive at Nabble.com.


Back to the top