Search in sources :

Example 1 with Http11SslContextSpec

use of reactor.netty.http.Http11SslContextSpec in project spring-boot by spring-projects.

the class NettyRSocketServerFactoryTests method createSecureHttpClient.

private HttpClient createSecureHttpClient() {
    HttpClient httpClient = createHttpClient();
    Http11SslContextSpec sslContextSpec = Http11SslContextSpec.forClient().configure((builder) -> builder.sslProvider(SslProvider.JDK).trustManager(InsecureTrustManagerFactory.INSTANCE));
    return httpClient.secure((spec) -> spec.sslContext(sslContextSpec));
}
Also used : HttpClient(reactor.netty.http.client.HttpClient) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec)

Example 2 with Http11SslContextSpec

use of reactor.netty.http.Http11SslContextSpec in project spring-framework by spring-projects.

the class ReactorHttpsServer method initServer.

@Override
protected void initServer() throws Exception {
    SelfSignedCertificate cert = new SelfSignedCertificate();
    Http11SslContextSpec http11SslContextSpec = Http11SslContextSpec.forServer(cert.certificate(), cert.privateKey());
    this.reactorHandler = createHttpHandlerAdapter();
    this.reactorServer = reactor.netty.http.server.HttpServer.create().host(getHost()).port(getPort()).secure(sslContextSpec -> sslContextSpec.sslContext(http11SslContextSpec));
}
Also used : Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec) SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) ReactorHttpHandlerAdapter(org.springframework.http.server.reactive.ReactorHttpHandlerAdapter) InetSocketAddress(java.net.InetSocketAddress) AtomicReference(java.util.concurrent.atomic.AtomicReference) DisposableServer(reactor.netty.DisposableServer) SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec)

Example 3 with Http11SslContextSpec

use of reactor.netty.http.Http11SslContextSpec in project spring-boot by spring-projects.

the class AbstractReactiveWebServerFactoryTests method buildTrustAllSslConnector.

protected ReactorClientHttpConnector buildTrustAllSslConnector() {
    Http11SslContextSpec sslContextSpec = Http11SslContextSpec.forClient().configure((builder) -> builder.sslProvider(SslProvider.JDK).trustManager(InsecureTrustManagerFactory.INSTANCE));
    HttpClient client = HttpClient.create().wiretap(true).secure((spec) -> spec.sslContext(sslContextSpec));
    return new ReactorClientHttpConnector(client);
}
Also used : HttpClient(reactor.netty.http.client.HttpClient) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec) ReactorClientHttpConnector(org.springframework.http.client.reactive.ReactorClientHttpConnector)

Example 4 with Http11SslContextSpec

use of reactor.netty.http.Http11SslContextSpec in project spring-boot by spring-projects.

the class AbstractReactiveWebServerFactoryTests method buildTrustAllSslWithClientKeyConnector.

protected ReactorClientHttpConnector buildTrustAllSslWithClientKeyConnector() throws Exception {
    KeyStore clientKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    try (InputStream stream = new FileInputStream("src/test/resources/test.jks")) {
        clientKeyStore.load(stream, "secret".toCharArray());
    }
    KeyManagerFactory clientKeyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    clientKeyManagerFactory.init(clientKeyStore, "password".toCharArray());
    Http11SslContextSpec sslContextSpec = Http11SslContextSpec.forClient().configure((builder) -> builder.sslProvider(SslProvider.JDK).trustManager(InsecureTrustManagerFactory.INSTANCE).keyManager(clientKeyManagerFactory));
    HttpClient client = HttpClient.create().wiretap(true).secure((spec) -> spec.sslContext(sslContextSpec));
    return new ReactorClientHttpConnector(client);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) HttpClient(reactor.netty.http.client.HttpClient) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec) KeyStore(java.security.KeyStore) FileInputStream(java.io.FileInputStream) ReactorClientHttpConnector(org.springframework.http.client.reactive.ReactorClientHttpConnector) KeyManagerFactory(javax.net.ssl.KeyManagerFactory)

Example 5 with Http11SslContextSpec

use of reactor.netty.http.Http11SslContextSpec in project spring-boot by spring-projects.

the class NettyRSocketServerFactoryTests method createSecureTcpClient.

private TcpClient createSecureTcpClient() {
    TcpClient tcpClient = createTcpClient();
    Http11SslContextSpec sslContextSpec = Http11SslContextSpec.forClient().configure((builder) -> builder.sslProvider(SslProvider.JDK).trustManager(InsecureTrustManagerFactory.INSTANCE));
    return tcpClient.secure((spec) -> spec.sslContext(sslContextSpec));
}
Also used : TcpClient(reactor.netty.tcp.TcpClient) Http11SslContextSpec(reactor.netty.http.Http11SslContextSpec)

Aggregations

Http11SslContextSpec (reactor.netty.http.Http11SslContextSpec)5 HttpClient (reactor.netty.http.client.HttpClient)3 ReactorClientHttpConnector (org.springframework.http.client.reactive.ReactorClientHttpConnector)2 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 InetSocketAddress (java.net.InetSocketAddress)1 KeyStore (java.security.KeyStore)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1 ReactorHttpHandlerAdapter (org.springframework.http.server.reactive.ReactorHttpHandlerAdapter)1 DisposableServer (reactor.netty.DisposableServer)1 TcpClient (reactor.netty.tcp.TcpClient)1