Search in sources :

Example 1 with TcpSslContextSpec

use of reactor.netty.tcp.TcpSslContextSpec in project reactor-netty by reactor.

the class Application method main.

public static void main(String[] args) {
    File cert = new File("certificate.crt");
    File key = new File("private.key");
    TcpSslContextSpec tcpSslContextSpec = TcpSslContextSpec.forServer(cert, key);
    DisposableServer server = TcpServer.create().secure(spec -> spec.sslContext(tcpSslContextSpec)).bindNow();
    server.onDispose().block();
}
Also used : TcpSslContextSpec(reactor.netty.tcp.TcpSslContextSpec) TcpServer(reactor.netty.tcp.TcpServer) DisposableServer(reactor.netty.DisposableServer) File(java.io.File) DisposableServer(reactor.netty.DisposableServer) File(java.io.File) TcpSslContextSpec(reactor.netty.tcp.TcpSslContextSpec)

Example 2 with TcpSslContextSpec

use of reactor.netty.tcp.TcpSslContextSpec in project reactor-netty by reactor.

the class Application method main.

public static void main(String[] args) {
    TcpSslContextSpec tcpSslContextSpec = TcpSslContextSpec.forClient();
    Connection connection = TcpClient.create().host("example.com").port(443).secure(spec -> spec.sslContext(tcpSslContextSpec)).connectNow();
    connection.onDispose().block();
}
Also used : TcpClient(reactor.netty.tcp.TcpClient) TcpSslContextSpec(reactor.netty.tcp.TcpSslContextSpec) Connection(reactor.netty.Connection) Connection(reactor.netty.Connection) TcpSslContextSpec(reactor.netty.tcp.TcpSslContextSpec)

Example 3 with TcpSslContextSpec

use of reactor.netty.tcp.TcpSslContextSpec in project reactor-netty by reactor.

the class DiscardClient method main.

public static void main(String[] args) {
    TcpClient client = TcpClient.create().port(PORT).wiretap(WIRETAP);
    if (SECURE) {
        TcpSslContextSpec tcpSslContextSpec = TcpSslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
        client = client.secure(spec -> spec.sslContext(tcpSslContextSpec));
    }
    Connection connection = client.handle((in, out) -> {
        // Discards the incoming data and releases the buffers
        in.receive().subscribe();
        return out.sendString(Flux.interval(Duration.ofMillis(100)).map(l -> l + ""));
    }).connectNow();
    connection.onDispose().block();
}
Also used : TcpClient(reactor.netty.tcp.TcpClient) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) Flux(reactor.core.publisher.Flux) TcpSslContextSpec(reactor.netty.tcp.TcpSslContextSpec) Duration(java.time.Duration) Connection(reactor.netty.Connection) TcpClient(reactor.netty.tcp.TcpClient) Connection(reactor.netty.Connection) TcpSslContextSpec(reactor.netty.tcp.TcpSslContextSpec)

Example 4 with TcpSslContextSpec

use of reactor.netty.tcp.TcpSslContextSpec in project reactor-netty by reactor.

the class EchoClient method main.

public static void main(String[] args) {
    TcpClient client = TcpClient.create().port(PORT).wiretap(WIRETAP);
    if (SECURE) {
        TcpSslContextSpec tcpSslContextSpec = TcpSslContextSpec.forClient().configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));
        client = client.secure(spec -> spec.sslContext(tcpSslContextSpec));
    }
    Connection connection = client.handle((in, out) -> out.send(Flux.concat(ByteBufFlux.fromString(Mono.just("echo")), in.receive().retain()))).connectNow();
    connection.onDispose().block();
}
Also used : TcpClient(reactor.netty.tcp.TcpClient) InsecureTrustManagerFactory(io.netty.handler.ssl.util.InsecureTrustManagerFactory) Flux(reactor.core.publisher.Flux) ByteBufFlux(reactor.netty.ByteBufFlux) TcpSslContextSpec(reactor.netty.tcp.TcpSslContextSpec) Mono(reactor.core.publisher.Mono) Connection(reactor.netty.Connection) TcpClient(reactor.netty.tcp.TcpClient) Connection(reactor.netty.Connection) TcpSslContextSpec(reactor.netty.tcp.TcpSslContextSpec)

Aggregations

TcpSslContextSpec (reactor.netty.tcp.TcpSslContextSpec)4 Connection (reactor.netty.Connection)3 TcpClient (reactor.netty.tcp.TcpClient)3 InsecureTrustManagerFactory (io.netty.handler.ssl.util.InsecureTrustManagerFactory)2 Flux (reactor.core.publisher.Flux)2 File (java.io.File)1 Duration (java.time.Duration)1 Mono (reactor.core.publisher.Mono)1 ByteBufFlux (reactor.netty.ByteBufFlux)1 DisposableServer (reactor.netty.DisposableServer)1 TcpServer (reactor.netty.tcp.TcpServer)1