Search code examples
spring-bootrsocketrsocket-java

How to config SSL/TLS in spring boot with rsocket?


I have read the related question in stackoverflow. However, the answer only tell how to config about auth check. I need to encrpt all transferred data with rsocket in spring boot. How can I use tls in spring boot with SSL/TLS. I can't find any supported method when I init my rsocket client as shown below, although I know that rsocket it self can support SSL/TLS. I find some examples: The example

        this.rsocketRequester = rsocketRequesterBuilder.setupRoute("sidecar-client")
            .setupData("test_data")
            .rsocketConnector(connector -> connector.acceptor(responder))
            .connectTcp("localhost", 7000)
            .block();

Summary of my question:
1. Does rsocket in springboot support SSL/TLS ?
2. If spring boot support rsocket with SSL/TLS, are there any examples can be referenced

Solution

  • Yes, modifying your example

    Secure TCP (SSL)

    this.rsocketRequester = rsocketRequesterBuilder.setupRoute("sidecar-client")
                .setupData("test_data")
                .rsocketConnector(connector -> connector.acceptor(responder))
                .connect(TcpClientTransport.create(TcpClient.create().secure().host("localhost").port(7000)))
                .block();
    

    or secure websockets

    this.rsocketRequester = rsocketRequesterBuilder.setupRoute("sidecar-client")
                .setupData("test_data")
                .rsocketConnector(connector -> connector.acceptor(responder))
                      .connectWebSocket(URI.create("https://rsocket-demo.herokuapp.com/rsocket"))
                .block();