2
votes

I have a websocket server (API of jetty 9.0.1.v20130408), which worked fine without ssl. Now I configured my server like this:

SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath("/src/main/resources/keystore.jks");
sslContextFactory.setKeyStorePassword(password); 
sslContextFactory.setTrustStorePath("/src/main/resources/truststore.jks");
sslContextFactory.setTrustStorePassword(password); 
ConnectionFactory sslConnFactory = new SslConnectionFactory(sslContextFactory, "http/1.1);
connector.addConnectionFactory(sslConnFactory);
server.addConnector(connector);

No I tried to configurate the client. I thought, that on the client side I need to set path to truststore.jks and the password. But then I get on client.start() the Exception: SSL doesn't have a valid keystore. When I set the keystore, then I get on client.connect java.nio.channels.WritePendingException. Here is the code for my client:

WebSocketClient client = new WebSocketClient(sslContextFactory);
URI wssUri = new URI("wss://localhost:"+port);
sslContextFactory.start();
client.start();
client.connect(myClientSocket, wssUri);

Can anybody help me? I also tried on server side to set setWantClientAuth(false) and setTrustall(true), but it also did not work this way;

ADDED:

I generate my ssl files with keytool.

$ keytool -genkeypair -alias certificatekey -keyalg RSA -validity 365 -keystore keystore.jks 
$ keytool -export -alias certificatekey -keystore keystore.jks -rfc -file selfsignedcert.cer
$ keytool -import -alias certificatekey -file selfsignedcert.cer -keystore truststore.jks
1
Are you trying to use client certificates? or just standard SSL? - Joakim Erdfelt
SSL is new to me. So I generated files like keystore.jks, truststore.jks and certifcate.cert with keytool. For generating the files I followed the tutorial: techbrainwave.com/?p=953. For now I am using the same files for client and the server. - Salvadora
I added the keytool commands I used for generating the files to my first post. - Salvadora

1 Answers

1
votes

This is because UpgradeRequest is sent twice, as reported here

You can ignore the warning for now. Just use 9.0.4 when it is released.