How to use Spring WebSocketClient with SSL?

后端 未结 1 1238
谎友^
谎友^ 2021-01-06 01:45

I connect with my websocket client to non-SSL endpoint without any problem. But I cannot find any way how to connect to wss (SSL) endpoint. Where can I define the SSL factor

相关标签:
1条回答
  • 2021-01-06 02:21

    I think that each websocket container implementation provides ways to do this. You have to set this configuration using the StandardWebSocketClient .setUserProperties. All those properties are internally set in the ClientEndpointConfig used by the client.

    Here's an example with Tomcat as a provider:

    StandardWebSocketClient wsClient = //...;
    SSLContext sslContext = //...;
    wsClient.setUserProperties(WsWebSocketContainer.SSL_CONTEXT_PROPERTY, sslContext);
    

    In any case you should refer to your provider reference documentation to know which configuration keys you should use.

    0 讨论(0)
提交回复
热议问题