Skip to content

Commit

Permalink
add SslContext builder with h2 disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
argha-c committed Nov 13, 2020
1 parent 8199335 commit af3d244
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,28 @@ public static SslContext configureSSL(SslContextFactory sslContextFactory, Strin

return sslContext;
}

/**
* This is meant to be use in cases where the server wishes not to advertise h2 as part of ALPN.
*/
private SslContext configureSSLWithH2Disabled(SslContextFactory sslContextFactory, String host) {

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,
ApplicationProtocolNames.HTTP_1_1);
final SslContext sslContext;
try {
sslContext = sslContextFactory.createBuilderForServer().applicationProtocolConfig(apn).build();
} catch (SSLException e) {
throw new RuntimeException("Error configuring SslContext with ALPN!", e);
}

sslContextFactory.enableSessionTickets(sslContext);
sslContextFactory.configureOpenSslStatsMetrics(sslContext, host);
return sslContext;
}
}

0 comments on commit af3d244

Please sign in to comment.