Skip to content

Commit

Permalink
Always allow h2 for ALPN for h2 config
Browse files Browse the repository at this point in the history
  • Loading branch information
argha-c committed Nov 10, 2020
1 parent 15179f4 commit 0ec80df
Showing 1 changed file with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,21 @@ public static SslContext configureSSL(SslContextFactory sslContextFactory, int p
public static SslContext configureSSL(SslContextFactory sslContextFactory, String metricId) {
SslContextBuilder builder = sslContextFactory.createBuilderForServer();

String[] supportedProtocol;
if (HTTP2_DISABLED.get()) {
supportedProtocol = new String[]{ApplicationProtocolNames.HTTP_1_1};
}
else {
supportedProtocol = new String[]{ApplicationProtocolNames.HTTP_2,
ApplicationProtocolNames.HTTP_1_1};
}

String[] supportedProtocols = new String[]{ApplicationProtocolNames.HTTP_2, ApplicationProtocolNames.HTTP_1_1};
ApplicationProtocolConfig apn = new ApplicationProtocolConfig(
ApplicationProtocolConfig.Protocol.ALPN,
// NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
ApplicationProtocolConfig.SelectorFailureBehavior.NO_ADVERTISE,
// ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
ApplicationProtocolConfig.SelectedListenerFailureBehavior.ACCEPT,
supportedProtocol);
supportedProtocols);

final SslContext sslContext;
try {
sslContext = builder
.applicationProtocolConfig(apn)
.build();
}
catch (SSLException e) {
} catch (SSLException e) {
throw new RuntimeException("Error configuring SslContext with ALPN!", e);
}

Expand Down

0 comments on commit 0ec80df

Please sign in to comment.