Fix for SSL

This commit is contained in:
Frédéric Brégier 2012-07-22 19:38:54 +03:00
parent b60a9f6532
commit 258f5b00fa

View File

@ -17,21 +17,28 @@ package org.jboss.netty.example.http.upload;
import static org.jboss.netty.channel.Channels.*; import static org.jboss.netty.channel.Channels.*;
import javax.net.ssl.SSLEngine;
import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory; import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.example.securechat.SecureChatSslContextFactory;
import org.jboss.netty.handler.codec.http.HttpContentCompressor; import org.jboss.netty.handler.codec.http.HttpContentCompressor;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder; import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.jboss.netty.handler.codec.http.HttpResponseEncoder; import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
import org.jboss.netty.handler.ssl.SslHandler;
public class HttpUploadServerPipelineFactory implements ChannelPipelineFactory { public class HttpUploadServerPipelineFactory implements ChannelPipelineFactory {
public ChannelPipeline getPipeline() throws Exception { public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation. // Create a default pipeline implementation.
ChannelPipeline pipeline = pipeline(); ChannelPipeline pipeline = pipeline();
// Uncomment the following line if you want HTTPS if (HttpUploadServer.isSSL) {
//SSLEngine engine = SecureChatSslContextFactory.getServerContext().createSSLEngine(); SSLEngine engine = SecureChatSslContextFactory.getServerContext().createSSLEngine();
//engine.setUseClientMode(false); engine.setUseClientMode(false);
//pipeline.addLast("ssl", new SslHandler(engine)); SslHandler handler = new SslHandler(engine);
handler.setIssueHandshake(true);
pipeline.addLast("ssl", handler);
}
pipeline.addLast("decoder", new HttpRequestDecoder()); pipeline.addLast("decoder", new HttpRequestDecoder());