private ChannelHandler createSslHandler(SSLContext sslContext) { SSLEngine sslEngine = sslContext.createSSLEngine(); sslEngine.setUseClientMode(true); return new SslHandler(sslEngine); }
/** * Adds the ssl handler * * @param pipeline - channel pipeline */ protected void addSslHandler(ChannelPipeline pipeline) { if (sslContext != null) { SSLEngine engine = sslContext.createSSLEngine(); engine.setUseClientMode(false); pipeline.addLast(SSL_HANDLER, new SslHandler(engine)); } }
private ChannelHandler createSslHandler(SSLContext sslContext, boolean needsClientAuth) { SSLEngine sslEngine = sslContext.createSSLEngine(); sslEngine.setUseClientMode(false); if (needsClientAuth) { sslEngine.setNeedClientAuth(true); } return new SslHandler(sslEngine); }
/** * Create a new SslHandler. * @see #newHandler(ByteBufAllocator) */ protected SslHandler newHandler(ByteBufAllocator alloc, boolean startTls) { return new SslHandler(newEngine(alloc), startTls); }
/** * Create a new SslHandler. * @see #newHandler(ByteBufAllocator, String, int, boolean) */ protected SslHandler newHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls) { return new SslHandler(newEngine(alloc, peerHost, peerPort), startTls); }
@Override protected final SslHandler newHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls) { return new SslHandler(newEngine0(alloc, peerHost, peerPort, false), startTls); }
@Override protected final SslHandler newHandler(ByteBufAllocator alloc, boolean startTls) { return new SslHandler(newEngine0(alloc, null, -1, false), startTls); }
private SslHandler createSslHandler( ChannelHandlerContext ctx, InetSocketAddress inetSocketAddress ) { SSLEngine sslEngine = sslContext.newEngine( ctx.alloc(), inetSocketAddress.getHostName(), inetSocketAddress.getPort() ); for ( Function<SSLEngine,SSLEngine> mod : engineModifications ) { sslEngine = mod.apply( sslEngine ); } // Don't need to set tls versions since that is set up from the context return new SslHandler( sslEngine ); }
@Override public ChannelHandler call() throws Exception { try { return new SslHandler(createSslEngine(input)); } catch (SSLException e) { LOG.error("Error creating SSL context. Make sure the certificate and key are in the correct format: cert=X.509 key=PKCS#8"); throw e; } }
@Override public SslHandler apply(final HttpsCertificate certificate) { SSLEngine sslEngine = certificate.createSSLEngine(); sslEngine.setUseClientMode(false); return new SslHandler(sslEngine); } };
@Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addFirst(new SslHandler(engine)); setupHandlers(ch, dispatcher, HTTPS); } };
/** * Create a new SslHandler. * @see #newHandler(ByteBufAllocator, String, int, boolean) */ protected SslHandler newHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls) { return new SslHandler(newEngine(alloc, peerHost, peerPort), startTls); }
@Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addFirst(new SslHandler(engine)); setupHandlers(ch, dispatcher, HTTPS); } };
/** * Create a new SslHandler. * @see #newHandler(ByteBufAllocator) */ protected SslHandler newHandler(ByteBufAllocator alloc, boolean startTls) { return new SslHandler(newEngine(alloc), startTls); }
@Override protected final SslHandler newHandler(ByteBufAllocator alloc, boolean startTls) { return new SslHandler(newEngine0(alloc, null, -1, false), startTls); }
@Override protected final SslHandler newHandler(ByteBufAllocator alloc, String peerHost, int peerPort, boolean startTls) { return new SslHandler(newEngine0(alloc, peerHost, peerPort, false), startTls); }
private synchronized void initSSL(ChannelPipeline pipeline) throws SSLContextException { if (sslContext == null || sslEngine == null) { try (X509Util x509Util = new ClientX509Util()) { sslContext = x509Util.createSSLContext(clientConfig); sslEngine = sslContext.createSSLEngine(host, port); sslEngine.setUseClientMode(true); } } pipeline.addLast("ssl", new SslHandler(sslEngine)); LOG.info("SSL handler added for channel: {}", pipeline.channel()); } }
private ChannelHandler nettyServerHandler( Channel channel, SslContext sslContext ) { SSLEngine sslEngine = sslContext.newEngine( channel.alloc() ); return new SslHandler( sslEngine ); }
private SslHandler createSslHandler(String peerHost, int peerPort) { SSLEngine sslEngine = sslEngineFactory.newSslEngine(config, peerHost, peerPort); SslHandler sslHandler = new SslHandler(sslEngine); if (handshakeTimeout > 0) sslHandler.setHandshakeTimeoutMillis(handshakeTimeout); return sslHandler; }
@Override public NetSocket upgradeToSsl(String serverName, Handler<Void> handler) { ChannelOutboundHandler sslHandler = (ChannelOutboundHandler) chctx.pipeline().get("ssl"); if (sslHandler == null) { chctx.pipeline().addFirst("handshaker", new SslHandshakeCompletionHandler(ar -> { if (ar.succeeded()) { handler.handle(null); } else { chctx.channel().closeFuture(); handleException(ar.cause()); } })); if (remoteAddress != null) { sslHandler = new SslHandler(helper.createEngine(vertx, remoteAddress, serverName)); } else { if (helper.isSNI()) { sslHandler = new SniHandler(helper.serverNameMapper(vertx)); } else { sslHandler = new SslHandler(helper.createEngine(vertx)); } } chctx.pipeline().addFirst("ssl", sslHandler); } return this; }