Browse Source

Adapt ReactorHttpsServer to lates Reactor Netty changes

pull/1847/merge
Violeta Georgieva 6 years ago committed by Rossen Stoyanchev
parent
commit
22f6e5b9ff
  1. 21
      spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/ReactorHttpsServer.java

21
spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/ReactorHttpsServer.java

@ -16,12 +16,18 @@ @@ -16,12 +16,18 @@
package org.springframework.http.server.reactive.bootstrap;
import java.security.cert.CertificateException;
import java.util.concurrent.atomic.AtomicReference;
import reactor.core.Exceptions;
import reactor.netty.DisposableServer;
import reactor.netty.tcp.SslProvider.DefaultConfigurationType;
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.SelfSignedCertificate;
/**
* @author Stephane Maldini
*/
@ -37,9 +43,20 @@ public class ReactorHttpsServer extends AbstractHttpServer { @@ -37,9 +43,20 @@ public class ReactorHttpsServer extends AbstractHttpServer {
@Override
protected void initServer() {
this.reactorHandler = createHttpHandlerAdapter();
SelfSignedCertificate cert = null;
try {
cert = new SelfSignedCertificate();
}
catch (CertificateException e) {
throw Exceptions.propagate(e);
}
SslContextBuilder sslContextBuilder =
SslContextBuilder.forServer(cert.certificate(), cert.privateKey());
this.reactorServer = reactor.netty.http.server.HttpServer.create()
.tcpConfiguration(server -> server.host(getHost()).secure())
.port(getPort());
.host(getHost())
.port(getPort())
.secure(sslContextSpec -> sslContextSpec.sslContext(sslContextBuilder)
.defaultConfiguration(DefaultConfigurationType.TCP));
}
private ReactorHttpHandlerAdapter createHttpHandlerAdapter() {

Loading…
Cancel
Save