Skip to content

Commit

Permalink
ISPN-14240 Use parent channel to obtain SslHandler when using HTTP/2
Browse files Browse the repository at this point in the history
  • Loading branch information
tristantarrant committed Oct 18, 2022
1 parent 9791c1d commit 2d40145
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static void addCommonHandlers(ChannelPipeline pipeline, RestServer restS

private static void configureHttpPipeline(ChannelPipeline pipeline, RestServer restServer) {
//TODO [ISPN-12082]: Rework pipeline removing deprecated codecs
Http2MultiplexCodec multiplexCodec = Http2MultiplexCodecBuilder.forServer(new ChannelInitializer<Channel>() {
Http2MultiplexCodec multiplexCodec = Http2MultiplexCodecBuilder.forServer(new ChannelInitializer<>() {
@Override
protected void initChannel(Channel channel) {
// Creates the HTTP/2 pipeline, where each stream is handled by a sub-channel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.ssl.SslHandler;
import io.netty.util.AttributeKey;

Expand Down Expand Up @@ -57,7 +58,11 @@ public String getFirstRequestHeaderValue(String s) {

@Override
public SSLSession getSSLSession() {
SslHandler sslHandler = (SslHandler) ctx.pipeline().get(SslHandler.class.getName());
ChannelPipeline pipeline = ctx.pipeline();
SslHandler sslHandler = (SslHandler) pipeline.get(SslHandler.class.getName());
if (sslHandler == null && pipeline.channel().parent() != null) {
sslHandler = (SslHandler) pipeline.channel().parent().pipeline().get(SslHandler.class.getName());
}
return sslHandler != null ? sslHandler.engine().getSession() : null;
}

Expand Down

0 comments on commit 2d40145

Please sign in to comment.