Problem when using the HTTP client with SSL through a proxy

Giovanni giovanni.mels at agfa.com
Tue Aug 17 06:15:22 EDT 2010


Ok, I tried a different (better) approach: adding the SSL handler to the
pipeline after the connect request was sent to the proxy, but I still get
the same exceptions


        // Enable HTTPS if necessary.
	if (sslContext != null) {
		log.info("adding ssl to pipeline");
		SSLEngine engine = sslContext.createSSLEngine();
		engine.setUseClientMode(true);
		SslHandler sslHandler = new SslHandler(engine);
			
		channel.getPipeline().addFirst("ssl", sslHandler);
		ChannelFuture handshake = sslHandler.handshake();
		handshake.awaitUninterruptibly();
			
		if (!handshake.isSuccess()) {
			log.error("ssl handshake failed");
			handshake.getCause().printStackTrace();
			bootstrap.releaseExternalResources();
			return;
		}
			
		log.info("handshake sucessful");
	}



2010-08-17 11:59:30,773 [main:] connected to proxy!
2010-08-17 11:59:30,788 [main:] connected to server
2010-08-17 11:59:30,788 [main:] adding ssl to pipeline
2010-08-17 11:59:30,851 [New I/O client worker #1-1:]
DefaultChannelPipeline{(codec =
org.jboss.netty.handler.codec.http.HttpClientCodec), (inflater =
org.jboss.netty.handler.codec.http.HttpContentDecompressor), (handler =
test.netty.HttpResponseHandler)}
STATUS: 200 Connection established
VERSION: HTTP/1.1

2010-08-17 11:59:31,397 [main:] handshake sucessful
2010-08-17 11:59:31,397 [main:] get succesful
2010-08-17 11:59:31,428 [New I/O client worker #1-1:]
DefaultChannelPipeline{(ssl = org.jboss.netty.handler.ssl.SslHandler),
(codec = org.jboss.netty.handler.codec.http.HttpClientCodec), (inflater =
org.jboss.netty.handler.codec.http.HttpContentDecompressor), (handler =
test.netty.HttpResponseHandler)}
17-aug-2010 11:59:31 org.jboss.netty.channel.SimpleChannelUpstreamHandler
WARNING: EXCEPTION, please implement
test.netty.HttpResponseHandler.exceptionCaught() for proper handling.
java.lang.ClassCastException:
org.jboss.netty.buffer.BigEndianHeapChannelBuffer cannot be cast to
org.jboss.netty.handler.codec.http.HttpResponse
	at
test.netty.HttpResponseHandler.messageReceived(HttpResponseHandler.java:102)
	at
org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived(HttpContentDecoder.java:131)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndfireMessageReceived(ReplayingDecoder.java:513)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:497)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:434)
	at
org.jboss.netty.handler.codec.http.HttpClientCodec.handleUpstream(HttpClientCodec.java:77)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
	at
org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:317)
	at
org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:299)
	at
org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:216)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
	at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349)
	at
org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:281)
	at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:201)
	at
org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:619)


The message again contains the bytes for "HTTP/1.1 200 Connection
established".

I could really use some help here...

Thanks,
Giovanni
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Problem-when-using-the-HTTP-client-with-SSL-through-a-proxy-tp5427385p5431425.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list