1

I have created two classes server and client. Server starting with ssl as below

HttpServer server =
  vertx.createHttpServer(new HttpServerOptions().setSsl(true).setKeyStoreOptions(
    new JksOptions().setPath("server-keystore.jks").setPassword("wibble")
  ));

Also one more i.e. client

vertx.createHttpClient(new HttpClientOptions().setSsl(true)).getNow(4443, "localhost", "/", resp -> {
      System.out.println("Got response " + resp.statusCode());
      resp.bodyHandler(body -> System.out.println("Got data " + body.toString("ISO-8859-1")));
    });

While running both On client I am getting "Failed to create SSL connection". Is there any way to configure anything related to ssl?

sanghavi7
  • 758
  • 1
  • 15
  • 38
  • If I write .setTrustAll(true) it connect. but that is threat. So How can I connect without trusting all. – sanghavi7 Apr 11 '17 at 10:24
  • Add your certificate to the `TrustOptions` or use a valid certificate for your server http://vertx.io/docs/vertx-core/java/#_client_trust_configuration – tsegismont Apr 11 '17 at 14:38

1 Answers1

3

To enable ssl in vertx you can use keystore.jks file

Then use following configuration :

HttpServerOptions secureOptions = new HttpServerOptions();
    if (Configuration.SSL_enabled) {
        LOG.debug("Secure Transport Protocol [ SSL/TLS ] has been enabled !!! ");
        secureOptions.setSsl(true)
                .setKeyStoreOptions(new JksOptions().setPath(Configuration.SSL_filename)
                        .setPassword(Configuration.SSL_password))
                .setTrustStoreOptions(new JksOptions().setPath(Configuration.SSL_filename)
                        .setPassword(Configuration.SSL_password))
                .addEnabledSecureTransportProtocol(Constants.TLS_VERSION_1)
                .addEnabledSecureTransportProtocol(Constants.TLS_VERSION_2);

    }

   vertx.createHttpServer(secureOptions).requestHandler(router::accept).listen(Configuration.port);

I hope this will help you :)

Shasha
  • 669
  • 1
  • 8
  • 26