use of io.dropwizard.jetty.SslReload in project dropwizard by dropwizard.
the class SslReloadTaskTest method reloadsMultiple.
@Test
void reloadsMultiple() throws Exception {
SslReload ok1 = mock(SslReload.class);
SslReload ok2 = mock(SslReload.class);
SslReloadTask reloadTask = new SslReloadTask();
reloadTask.setReloaders(Sets.of(ok1, ok2));
reloadTask.execute(emptyMap(), mock(PrintWriter.class));
verify(ok1, times(1)).reload();
verify(ok2, times(1)).reload();
}
use of io.dropwizard.jetty.SslReload in project dropwizard by dropwizard.
the class SslReloadTaskTest method failingDryRunSkipsAll.
@Test
void failingDryRunSkipsAll() throws Exception {
SslReload failingDryRun = mock(SslReload.class);
doThrow(new RuntimeException("Dry run failed")).when(failingDryRun).reloadDryRun();
SslReload ok = mock(SslReload.class);
SslReloadTask reloadTask = new SslReloadTask();
reloadTask.setReloaders(Sets.of(failingDryRun, ok));
assertThat(catchRuntimeException(() -> reloadTask.execute(emptyMap(), mock(PrintWriter.class))).getMessage()).isEqualTo("Dry run failed");
verify(failingDryRun, never()).reload();
verify(ok, never()).reload();
}
use of io.dropwizard.jetty.SslReload in project dropwizard by dropwizard.
the class Http2ConnectorFactory method build.
@Override
public Connector build(Server server, MetricRegistry metrics, String name, @Nullable ThreadPool threadPool) {
// HTTP/2 requires that a server MUST support TLSv1.2 or higher and TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher
// See https://datatracker.ietf.org/doc/html/rfc7540#section-9.2
setSupportedProtocols(Arrays.asList("TLSv1.3", "TLSv1.2"));
checkSupportedCipherSuites();
// Setup connection factories
final HttpConfiguration httpConfig = buildHttpConfiguration();
final HttpConnectionFactory http1 = buildHttpConnectionFactory(httpConfig);
final HTTP2ServerConnectionFactory http2 = new HTTP2ServerConnectionFactory(httpConfig);
http2.setMaxConcurrentStreams(maxConcurrentStreams);
http2.setInitialStreamRecvWindow(initialStreamRecvWindow);
final NegotiatingServerConnectionFactory alpn = new ALPNServerConnectionFactory();
// Speak HTTP 1.1 over TLS if negotiation fails
alpn.setDefaultProtocol("http/1.1");
final SslContextFactory sslContextFactory = configureSslContextFactory(new SslContextFactory.Server());
sslContextFactory.addLifeCycleListener(logSslParameters(sslContextFactory));
server.addBean(sslContextFactory);
server.addBean(new SslReload(sslContextFactory, this::configureSslContextFactory));
// We should use ALPN as a negotiation protocol. Old clients that don't support it will be served
// via HTTPS. New clients, however, that want to use HTTP/2 will use TLS with ALPN extension.
// If negotiation succeeds, the client and server switch to HTTP/2 protocol.
final SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, "alpn");
return buildConnector(server, new ScheduledExecutorScheduler(), buildBufferPool(), name, threadPool, new InstrumentedConnectionFactory(sslConnectionFactory, metrics.timer(httpConnections())), alpn, http2, http1);
}
Aggregations