@Override public HttpServer apply(HttpServer server) { try { return server.secure((contextSpec) -> { SslProvider.DefaultConfigurationSpec spec = contextSpec .sslContext(getContextBuilder()); if (this.http2 != null && this.http2.isEnabled()) { spec.defaultConfiguration(SslProvider.DefaultConfigurationType.H2); } }); } catch (Exception ex) { throw new IllegalStateException(ex); } }
.defaultConfiguration(ssl.getDefaultConfigurationType()) .handshakeTimeout(ssl.getHandshakeTimeout()) .closeNotifyFlushTimeout(ssl.getCloseNotifyFlushTimeout())
SslContextBuilder.forClient() .trustManager(InsecureTrustManagerFactory.INSTANCE)) .defaultConfiguration(SslProvider.DefaultConfigurationType.TCP)) .post() .uri("/3")
(InsecureTrustManagerFactory .INSTANCE)) .defaultConfiguration(SslProvider .DefaultConfigurationType.TCP) .handshakeTimeoutMillis(30000))
@Test // @Ignore public void testHttpToHttp2Ssl() throws Exception { SelfSignedCertificate cert = new SelfSignedCertificate(); SslContextBuilder serverOptions = SslContextBuilder.forServer(cert.certificate(), cert.privateKey()); DisposableServer server = HttpServer.create() .secure(sslContextSpec -> sslContextSpec.sslContext(serverOptions) .defaultConfiguration(SslProvider.DefaultConfigurationType.H2)) .handle((req, res) -> res.sendString(Mono.just("Hello"))) .wiretap(true) .bindNow(); String response = HttpClient.create() .port(server.port()) .secure(ssl -> ssl.sslContext( SslContextBuilder.forClient() .trustManager(InsecureTrustManagerFactory.INSTANCE))) .wiretap(true) .get() .uri("/") .responseContent() .aggregate() .asString() .block(Duration.ofSeconds(30)); server.disposeNow(); }
@Override protected void initServer() throws Exception { SelfSignedCertificate cert = new SelfSignedCertificate(); SslContextBuilder builder = SslContextBuilder.forServer(cert.certificate(), cert.privateKey()); this.reactorHandler = createHttpHandlerAdapter(); this.reactorServer = reactor.netty.http.server.HttpServer.create() .host(getHost()) .port(getPort()) .secure(spec -> spec.sslContext(builder).defaultConfiguration(DefaultConfigurationType.TCP)); }