if (enableCompression) { ZlibEncoder encoder = new ZlibEncoder(compressionLevel); pipeline.addFirst("deflater", encoder); pipeline.addFirst("inflater", new ZlibDecoder()); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, managers, null); SSLEngine sslEngine = sslContext.createSSLEngine(); sslEngine.setUseClientMode(true); for (String protocol : sslEngine.getEnabledProtocols()) { if ((includeProtocols.isEmpty() || includeProtocols.contains(protocol)) && !excludeProtocols.contains(protocol)) { sslEngine.setEnabledProtocols(enabledProtocols.toArray(new String[0])); pipeline.addFirst("ssl", new SslHandler(sslEngine));
final String serverPath = config.getServerPath(); if (f.isSuccess()) { engine = sslContext.createSSLEngine(serverName, serverPort); } else { engine = sslContext.createSSLEngine(); engine.setUseClientMode(true); engine.setEnableSessionCreation(config.isEnableSslSessionCreation()); String[] enabledCipherSuites = config.getEnabledSslCipherSuites(); if (enabledCipherSuites != null) { engine.setEnabledCipherSuites(enabledCipherSuites); SslHandler sslHandler = new SslHandler(engine); realChannel.getPipeline().addFirst("ssl", sslHandler); sslHandshakeFuture = sslHandler.handshake(); future.setFailure(f.getCause()); fireExceptionCaught(virtualChannel, f.getCause());
final SSLEngine sslEngine = sslContext.createSSLEngine(host, port); final SSLParameters sslParameters = new SSLParameters(); sslParameters.setEndpointIdentificationAlgorithm("HTTPS"); sslEngine.setSSLParameters(sslParameters); sslEngine.setUseClientMode(true); final SslHandler sslHandler = new SslHandler( sslEngine, SslHandler.getDefaultBufferPool(), false, timer, sslHandler.setCloseOnSSLException(true); final ChannelPipeline pipeline = connectFuture.getChannel().getPipeline(); pipeline.addFirst("ssl", sslHandler); final ChannelFuture handshakeFuture = Channels.future(connectFuture.getChannel()); pipeline.addLast("connectionErrorHandler", new SimpleChannelUpstreamHandler() connectFuture.addListener( new ChannelFutureListener()
private SslHandler newHandler(SSLEngine engine) { SslHandler handler = new SslHandler(engine, bufferPool()); if (isClient()) { handler.setIssueHandshake(true); } handler.setCloseOnSSLException(true); return handler; } }
if (engine.isInboundDone() || engine.isOutboundDone()) { if (isEnableRenegotiation()) { handshake(); } else { fireExceptionCaught( ctx, new SSLException( "renegotiation attempted by peer; " + Channels.close(ctx, succeededFuture(ctx.getChannel()));
SSLContext tlsContext = SSLContext.getInstance("TLS"); tlsContext.init(keyManagers, trustManagers, random); SSLEngine tlsEngine = tlsContext.createSSLEngine(tlsHostname, tlsPort); tlsEngine.setUseClientMode(true); SSLParameters tlsParameters = tlsEngine.getSSLParameters(); tlsParameters.setEndpointIdentificationAlgorithm("HTTPS"); tlsParameters.setServerNames(asList(new SNIHostName(tlsHostname))); setApplicationProtocols(tlsParameters, applicationProtocols); tlsEngine.setSSLParameters(tlsParameters); SslHandler sslHandler = new SslHandler(tlsEngine); sslHandler.setIssueHandshake(true); return pipeline(sslHandler, new TlsClientChannelSource());
@Override public SocketChannel newChannel(ChannelPipeline pipeline) { try { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, new TrustManager[]{new BogusTrustManager()}, null); SSLEngine sslEngine = sslContext.createSSLEngine(); sslEngine.setUseClientMode(true); pipeline.addFirst("ssl", new SslHandler(sslEngine)); return super.newChannel(pipeline); } catch (Exception ex) { throw new RuntimeException("Cannot create SSL channel", ex); } } }
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); SSLEngine sslEngine = createServerSSLContext().createSSLEngine(); sslEngine.setUseClientMode(false); pipeline.addLast("ssl", new SslHandler(sslEngine)); return pipeline; } }
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline cp = super.getPipeline(); SSLEngine engine = context.createSSLEngine(); engine.setUseClientMode(false); cp.addFirst("sslHandler", new SslHandler(engine)); return cp; }
private SslHandler configureClientSSLOnDemand() throws Exception { if (!producer.getConfiguration().isSsl()) { return null; } if (producer.getConfiguration().getSslHandler() != null) { return producer.getConfiguration().getSslHandler(); } else if (sslContext != null) { SSLEngine engine = sslContext.createSSLEngine(); if (producer.getConfiguration().getSslContextParameters() == null) { // just set the enabledProtocols if the SslContextParameter doesn't set engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(",")); } engine.setUseClientMode(true); return new SslHandler(engine); } return null; }
public ChannelPipeline getPipeline() { ChannelPipeline pipeline = Channels.pipeline(); if (tcpHelper.isSSL()) { SSLEngine engine = tcpHelper.getSSLContext().createSSLEngine(); engine.setUseClientMode(false); switch (tcpHelper.getClientAuth()) { case REQUEST: { engine.setWantClientAuth(true); break; } case REQUIRED: { engine.setNeedClientAuth(true); break; } case NONE: { engine.setNeedClientAuth(false); break; } } pipeline.addLast("ssl", new SslHandler(engine)); } pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); // For large file / sendfile support pipeline.addLast("handler", new ServerHandler()); return pipeline; } });
OFChannelHandler handler = new OFChannelHandler(controller); ChannelPipeline pipeline = Channels.pipeline(); if (sslContext != null) { log.debug("OpenFlow SSL enabled."); SSLEngine sslEngine = sslContext.createSSLEngine(); sslEngine.setNeedClientAuth(true); sslEngine.setUseClientMode(false); sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols()); sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites()); sslEngine.setEnableSessionCreation(true); SslHandler sslHandler = new SslHandler(sslEngine); pipeline.addLast("ssl", sslHandler); } else { log.debug("OpenFlow SSL disabled."); pipeline.addLast("ofmessagedecoder", new OFMessageDecoder()); pipeline.addLast("ofmessageencoder", new OFMessageEncoder()); pipeline.addLast("idle", idleHandler); pipeline.addLast("timeout", readTimeoutHandler);
String enabledProtocols = Play.configuration.getProperty("play.ssl.enabledProtocols", ""); ChannelPipeline pipeline = pipeline(); SSLEngine engine = SslHttpServerContextFactory.getServerContext().createSSLEngine(); engine.setUseClientMode(false); engine.setEnabledCipherSuites(enabledCiphers.replaceAll(" ", "").split(",")); engine.setWantClientAuth(true); } else if ("need".equalsIgnoreCase(mode)) { engine.setNeedClientAuth(true); engine.setEnableSessionCreation(true); pipeline.addLast("ssl", new SslHandler(engine)); instance = getInstance(handler); if (instance != null) { pipeline.addLast(name, instance); sslPlayHandler.pipelines.put("Ssl" + name, instance); pipeline.addLast("handler", sslPlayHandler); sslPlayHandler.pipelines.put("SslHandler", sslPlayHandler);
@Override public void operationComplete(ChannelFuture future) throws Exception { CallbackConnectionListener callbackConnectionListener = new CallbackConnectionListener(remoteAddress, connectionCallback, openChannels); if (future.isSuccess()) { SSLParameters sslParameters = new SSLParameters(); sslParameters.setEndpointIdentificationAlgorithm("HTTPS"); SSLEngine sslEngine = SSLContext.getDefault().createSSLEngine(remoteAddress.getHostString(), remoteAddress.getPort()); sslEngine.setSSLParameters(sslParameters); sslEngine.setUseClientMode(true); SslHandler sslHandler = new SslHandler(sslEngine); future.getChannel().getPipeline().addBefore("codec", "ssl", sslHandler); ChannelFuture handshakeFuture = sslHandler.handshake(); handshakeFuture.addListener(callbackConnectionListener); } else { callbackConnectionListener.operationComplete(future); } } }
public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); if (tcpHelper.isSSL()) { SSLEngine engine = tcpHelper.getSSLContext().createSSLEngine(host, port); if (tcpHelper.isVerifyHost()) { SSLParameters sslParameters = engine.getSSLParameters(); sslParameters.setEndpointIdentificationAlgorithm("HTTPS"); engine.setSSLParameters(sslParameters); } engine.setUseClientMode(true); //We are on the client side of the connection pipeline.addLast("ssl", new SslHandler(engine)); } pipeline.addLast("encoder", new HttpRequestEncoder()); pipeline.addLast("decoder", new SwitchingHttpResponseDecoder()); pipeline.addLast("handler", new ClientHandler()); return pipeline; } });
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); if (sslOptions != null) { SSLEngine engine = sslOptions.context.createSSLEngine(); engine.setUseClientMode(true); engine.setEnabledCipherSuites(sslOptions.cipherSuites); SslHandler handler = new SslHandler(engine); handler.setCloseOnSSLException(true); pipeline.addLast("ssl", handler); } //pipeline.addLast("debug", new LoggingHandler(InternalLogLevel.INFO)); pipeline.addLast("frameDecoder", new Frame.Decoder()); pipeline.addLast("frameEncoder", frameEncoder); if (compressor != null) { pipeline.addLast("frameDecompressor", new Frame.Decompressor(compressor)); pipeline.addLast("frameCompressor", new Frame.Compressor(compressor)); } pipeline.addLast("messageDecoder", messageDecoder); pipeline.addLast("messageEncoder", protocolVersion == 1 ? messageEncoderV1 : messageEncoderV2); pipeline.addLast("dispatcher", connection.dispatcher); return pipeline; } }
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 ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast( "debug-client-head", new DebugHandler( "CLIENT_HEAD" ) ); if (this.clientContext.isSecure()) { SSLEngine sslEngine = this.clientContext.getSSLContext().createSSLEngine(); sslEngine.setUseClientMode( true ); SslHandler sslHandler = new SslHandler( sslEngine ); sslHandler.setEnableRenegotiation( false ); sslHandler.setIssueHandshake( true ); pipeline.addLast( "ssl", sslHandler ); pipeline.addLast( "client-post-ssl", new DebugHandler( "SERVER-POST-SSL" ) );
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); if (sslFactory != null) { pipeline.addLast("ssl", new SslHandler(sslFactory.createSSLEngine())); } pipeline.addLast("decoder", new HttpRequestDecoder()); pipeline.addLast("aggregator", new HttpChunkAggregator(1 << 16)); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("chunking", new ChunkedWriteHandler()); pipeline.addLast("shuffle", SHUFFLE); pipeline.addLast("idle", idleStateHandler); pipeline.addLast(TIMEOUT_HANDLER, new TimeoutHandler()); return pipeline; // TODO factor security manager into pipeline // TODO factor out encode/decode to permit binary shuffle // TODO factor out decode of index to permit alt. models }
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; }