I’m using springboot 5.2.1-Release and trying to build a Java websocket client to connect to our server through SSL.
I am able to connect with rest template without any issues.
But with websocket, it’s failing due to:
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid verification path to requested target
SSLContext sslCtx = SSContexts.custom().loadTrustMaterial( ... ).build();
StandardWebsocketClient wsClient = new StandardWebsocketClient();
Map<String,Object> props = wsClient.getUserProperties();
props.put( "SSL_CONTEXT", sslCtx )
wsClient.setUserProperties( props );
WebSocketStompClient stompClient = new WebSocketStompClient( wsClient );
stompClient.connect( url, sessionHandler );
I also tried
props.put( “org.apache.tomcat.websocket.SSL_CONTEXT”, sslCtx );
I’ve searched around but can’t find anyone with an example to do WebSocketClient over SSL in springboot.
Any help would be really appreciated.
Note the above SSLContext works with creating a RestTemplate.
TIA