I am trying to test an SSL connection between a Vertx HttpServer and HttpClient. Because I don't have any certificates, I created some self signed certificate like this:
keytool -genkeypair -alias selfsigned -keyalg RSA -keystore keystore.jks -storepass pass -keysize 2048 -validity 360
I have generated a public certificate as such:
keytool -export -alias selfsigned -keystore keystore.jks -rfc -file public.cert
And then I
keytool -import -file public.cert -alias public -keystore trustStore.jks
Then I tried adding them as JksOptions to the Server and Client in any possible order I could imagine and all of them generate the same error on the client side:
Future{cause=Failed to create SSL connection}
I don't understand what I do wrong and as much as I read about keystores and truststores, any combination didn't work for my program. If I set the client as trustAll(true), the connection happens succesfully.
Here are the settings for the server and the client:
HttpServerOptions httpServerOptions = new HttpServerOptions();
JksOptions options = new JksOptions();
options
.setPassword("pass")
.setPath("src/main/resources/file/keystore.jks");
httpServerOptions
.setSsl(true)
.setKeyStoreOptions(options);
HttpClientOptions httpClientOptions = new HttpClientOptions();
JksOptions options = new JksOptions();
options
.setPassword("pass")
.setPath("src/main/resources/file/trustStore.jks");
HttpClient client = vertx.createHttpClient(httpClientOptions
.setSsl(true)
.setTrustStoreOptions(options)
);
The code above appears in 2 separate Verticles and is run separately. What could be the issue?
- I have checked and the certificate does appear both in the keystore and truststore
- The CN = localhost, cause ultimately my client websocket does the following:
client.webSocket(8080, "127.0.0.1",... - I tried setting
.setVerifyHost(false), same result - I have tried the solutions in the other questions and they didn't work