From a82cf2fb7df5fa873f421f4b7bf2c4aea3a1e102 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 19 Jun 2020 16:36:11 +0200 Subject: [PATCH] Fix missing sslInfo with Reactor Netty and http/2 Prior to this commit, the `SslInfo` would be missing for WebFlux apps when deployed on Reactor Netty with http/2. This commit ensures that the request adapter checks the current channel and the parent channel for the presence of the `SslHander`. In the case of http/2, the `SslHander` is tied to the parent channel. Fixes gh-25286 See gh-25278 --- .../http/server/reactive/ReactorServerHttpRequest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java index 606c668200a4..cd3a2b345789 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ReactorServerHttpRequest.java @@ -22,6 +22,7 @@ import javax.net.ssl.SSLSession; +import io.netty.channel.Channel; import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.cookie.Cookie; import io.netty.handler.ssl.SslHandler; @@ -155,7 +156,11 @@ public InetSocketAddress getRemoteAddress() { @Override @Nullable protected SslInfo initSslInfo() { - SslHandler sslHandler = ((Connection) this.request).channel().pipeline().get(SslHandler.class); + Channel channel = ((Connection) this.request).channel(); + SslHandler sslHandler = channel.pipeline().get(SslHandler.class); + if (sslHandler == null && channel.parent() != null) { // HTTP/2 + sslHandler = channel.parent().pipeline().get(SslHandler.class); + } if (sslHandler != null) { SSLSession session = sslHandler.engine().getSession(); return new DefaultSslInfo(session);