Skip to content

Commit 20f02c1

Browse files
sotodelajaygeorge
authored andcommitted
Add "thrift" ALPN to ReloadableSslContext
1 parent 12651f8 commit 20f02c1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drift-transport-netty/src/main/java/com/facebook/drift/transport/netty/ssl/ReloadableSslContext.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
import com.google.common.hash.HashCode;
2020
import com.google.common.io.Files;
2121
import io.airlift.units.Duration;
22+
import io.netty.handler.ssl.ApplicationProtocolConfig;
23+
import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol;
24+
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior;
25+
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior;
2226
import io.netty.handler.ssl.SslContext;
2327
import io.netty.handler.ssl.SslContextBuilder;
2428

@@ -127,6 +131,11 @@ public synchronized void reload()
127131
if (!ciphers.isEmpty()) {
128132
sslContextBuilder.ciphers(ciphers);
129133
}
134+
// C++ ThriftServers expect the "thrift" ALPN value when using the legacy Header, Framed, and Unframed transports, to select an
135+
// appropriate handler without having to peek at the content of the connection. If the server doesn't support the legacy transports,
136+
// it should respond with a no_application_protocol alert and fail the TLS handshake.
137+
sslContextBuilder.applicationProtocolConfig(new ApplicationProtocolConfig(
138+
Protocol.ALPN, SelectorFailureBehavior.FATAL_ALERT, SelectedListenerFailureBehavior.FATAL_ALERT, new String[] {"thrift"}));
130139
sslContext.set(new SslContextHolder(sslContextBuilder.build()));
131140
}
132141
}

0 commit comments

Comments
 (0)