public SslHandler sslHandler() { final SSLContext context = sslContext.get(); if (context == null) { return null; } final SSLEngine engine = context.createSSLEngine(); engine.setUseClientMode(true); final SslHandler handler = new SslHandler(engine); handler.setEnableRenegotiation(false); handler.setIssueHandshake(true); return handler; }
public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = Channels.pipeline(); if (config.getAuthType() != Auth.PLAIN) { SSLEngine sslEngine = SSLContext.getDefault().createSSLEngine(); sslEngine.setUseClientMode(true); SslHandler sslHandler = new SslHandler(sslEngine); sslHandler.setEnableRenegotiation(true); pipeline.addLast("ssl", sslHandler); } pipeline.addLast("decoder", new StringDecoder()); pipeline.addLast("encoder", new StringEncoder()); // and then business logic. pipeline.addLast("handler", mailClientHandler); return pipeline; } }
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { ctx.setAttachment(e.getValue()); // Get the SslHandler in the current pipeline. SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class); sslHandler.setEnableRenegotiation(false); // Get notified when SSL handshake is done. ChannelFuture handshakeFuture = sslHandler.handshake(); handshakeFuture.addListener(new SslListener()); }
sslEngine.setUseClientMode( true ); SslHandler sslHandler = new SslHandler( sslEngine ); sslHandler.setEnableRenegotiation( false ); sslHandler.setIssueHandshake( true ); pipeline.addLast( "ssl", sslHandler );