@Override protected final void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<SslContext> future) throws Exception { if (!future.isSuccess()) { final Throwable cause = future.cause(); if (cause instanceof Error) { throw (Error) cause; } throw new DecoderException("failed to get the SslContext for " + hostname, cause); } SslContext sslContext = future.getNow(); selection = new Selection(sslContext, hostname); try { replaceHandler(ctx, hostname, sslContext); } catch (Throwable cause) { selection = EMPTY_SELECTION; PlatformDependent.throwException(cause); } }
private void configureHttps(ChannelPipeline p, @Nullable ProxiedAddresses proxiedAddresses) { assert sslContexts != null; p.addLast(new SniHandler(sslContexts)); p.addLast(TrafficLoggingHandler.SERVER); p.addLast(new Http2OrHttpHandler(proxiedAddresses)); }
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { super.decode(ctx, in, out); if (isHandShaked()) { // At this point Netty has replaced SNIHandler (formally this) with SSLHandler in the pipeline. // Now we need to add other handlers at the tail of the queue logger.debugf("Handshaked with hostname %s", hostname()); Optional<Route<SniRouteSource, HotRodServerRouteDestination>> route = routingTable.streamRoutes(SniRouteSource.class, HotRodServerRouteDestination.class) .filter(r -> r.getRouteSource().getSniHostName().equals(this.hostname())) .findAny(); HotRodServerRouteDestination routeDestination = route.orElseThrow(() -> logger.noRouteFound()).getRouteDesitnation(); ChannelInitializer<Channel> channelInitializer = routeDestination.getHotrodServer().getInitializer(); ctx.pipeline().addLast(channelInitializer); logger.debug("Replaced with route destination's handlers"); } }
@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; }
@Override protected final void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<SslContext> future) throws Exception { if (!future.isSuccess()) { final Throwable cause = future.cause(); if (cause instanceof Error) { throw (Error) cause; } throw new DecoderException("failed to get the SslContext for " + hostname, cause); } SslContext sslContext = future.getNow(); selection = new Selection(sslContext, hostname); try { replaceHandler(ctx, hostname, sslContext); } catch (Throwable cause) { selection = EMPTY_SELECTION; PlatformDependent.throwException(cause); } }
SniHandler sniHandler = new SniHandler(sslHelper.serverNameMapper(vertx)); ch.pipeline().addFirst("ssl", sniHandler); } else {
@Override protected final void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<SslContext> future) throws Exception { if (!future.isSuccess()) { final Throwable cause = future.cause(); if (cause instanceof Error) { throw (Error) cause; } throw new DecoderException("failed to get the SslContext for " + hostname, cause); } SslContext sslContext = future.getNow(); selection = new Selection(sslContext, hostname); try { replaceHandler(ctx, hostname, sslContext); } catch (Throwable cause) { selection = EMPTY_SELECTION; PlatformDependent.throwException(cause); } }
SniHandler sniHandler = new SniHandler(sslHelper.serverNameMapper(vertx)); pipeline.addFirst(sniHandler); } else {
@Override protected final void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<SslContext> future) throws Exception { if (!future.isSuccess()) { final Throwable cause = future.cause(); if (cause instanceof Error) { throw (Error) cause; } throw new DecoderException("failed to get the SslContext for " + hostname, cause); } SslContext sslContext = future.getNow(); selection = new Selection(sslContext, hostname); try { replaceHandler(ctx, hostname, sslContext); } catch (Throwable cause) { selection = EMPTY_SELECTION; PlatformDependent.throwException(cause); } }
@Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addFirst(new SniHandler(sniConfiguration.buildMapping())); setupHandlers(ch, dispatcher, HTTPS); } };
@Override protected final void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<SslContext> future) throws Exception { if (!future.isSuccess()) { final Throwable cause = future.cause(); if (cause instanceof Error) { throw (Error) cause; } throw new DecoderException("failed to get the SslContext for " + hostname, cause); } SslContext sslContext = future.getNow(); selection = new Selection(sslContext, hostname); try { replaceHandler(ctx, hostname, sslContext); } catch (Throwable cause) { selection = EMPTY_SELECTION; PlatformDependent.throwException(cause); } }
@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; }
@Override protected final void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<SslContext> future) throws Exception { if (!future.isSuccess()) { final Throwable cause = future.cause(); if (cause instanceof Error) { throw (Error) cause; } throw new DecoderException("failed to get the SslContext for " + hostname, cause); } SslContext sslContext = future.getNow(); selection = new Selection(sslContext, hostname); try { replaceHandler(ctx, hostname, sslContext); } catch (Throwable cause) { selection = EMPTY_SELECTION; PlatformDependent.throwException(cause); } }
SniHandler sniHandler = new SniHandler(sslHelper.serverNameMapper(vertx)); ch.pipeline().addFirst("ssl", sniHandler); } else {
SniHandler sniHandler = new SniHandler(sslHelper.serverNameMapper(vertx)); pipeline.addFirst(sniHandler); } else {
@Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addFirst(new SniHandler(sniConfiguration.buildMapping())); setupHandlers(ch, dispatcher, HTTPS); } };
@Override protected void initChannel(Channel ch) throws Exception { final ChannelPipeline p = ch.pipeline(); p.addLast(new FlushConsolidationHandler()); p.addLast(ReadSuppressingHandler.INSTANCE); if (port.protocol().isTls()) { p.addLast(new SniHandler(sslContexts)); p.addLast(TrafficLoggingHandler.SERVER); configureHttps(p); } else { p.addLast(TrafficLoggingHandler.SERVER); configureHttp(p); } }