example to configure mutual authentication Client
marcoberri opened this issue · 1 comments
marcoberri commented
you can have an example to configure a client / server web socket with mutual authentication in ssl?
I try this but i use jetty on spring boot... is corrected?
@Service
@Slf4j
public class StompClient {
private final String LOG = "[StompClient] --> ";
@Value("${web-socket.server.endpoint}")
private String URL;
private int numberOfConnections;
private WebSocketStompClient stompClient;
private StompSession stompSession;
private Map<String, StompSession> stompSessionMap = new HashMap<>();
private MutualAuthConfiguration mutualAuthConfiguration;
@Autowired
@Qualifier("MyStompSessionHandler")
private StompSessionHandler sessionHandler;
@Autowired
public StompClient(MutualAuthConfiguration mutualAuthConfiguration) throws GeneralSecurityException, IOException {
this.mutualAuthConfiguration = mutualAuthConfiguration;
SSLContext sslContext = new SSLContextBuilder()
.loadTrustMaterial(mutualAuthConfiguration.getTrustStore().getURL(), mutualAuthConfiguration.getTrustStorePassword().toCharArray())
.loadKeyMaterial(mutualAuthConfiguration.getKeyStore().getURL(), mutualAuthConfiguration.getKeyStorePassword().toCharArray(), mutualAuthConfiguration.getKeyPassword().toCharArray())
.build();
StandardWebSocketClient wsClient = new StandardWebSocketClient();
log.info("--->>> userProperties: {}",wsClient.getUserProperties());
//FIXME is OK? i don't find correct properties for jetty.
wsClient.getUserProperties().put("org.eclipse.jetty.server.SslConnectionFactory", sslContext);
List<Transport> transports = new ArrayList<>(2);
transports.add(new WebSocketTransport(wsClient));
transports.add(new RestTemplateXhrTransport());
WebSocketClient client = new SockJsClient(transports);
stompClient = new WebSocketStompClient(client);
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
}
....
....