Skip to content

Commit

Permalink
Fix missing sslInfo with Reactor Netty and http/2
Browse files Browse the repository at this point in the history
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 spring-projectsgh-25286
See spring-projectsgh-25278
  • Loading branch information
bclozel committed Jun 19, 2020
1 parent a6258b8 commit a82cf2f
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a82cf2f

Please sign in to comment.