List of usage examples for io.vertx.core.net SelfSignedCertificate trustOptions
PemTrustOptions trustOptions();
From source file:examples.NetExamples.java
License:Open Source License
public void example48(Vertx vertx) throws CertificateException { SelfSignedCertificate certificate = SelfSignedCertificate.create(); NetServerOptions serverOptions = new NetServerOptions().setSsl(true) .setKeyCertOptions(certificate.keyCertOptions()).setTrustOptions(certificate.trustOptions()); NetServer server = vertx.createNetServer(serverOptions) .connectHandler(socket -> socket.write("Hello!").end()).listen(1234, "localhost"); NetClientOptions clientOptions = new NetClientOptions().setSsl(true) .setKeyCertOptions(certificate.keyCertOptions()).setTrustOptions(certificate.trustOptions()); NetClient client = vertx.createNetClient(clientOptions); client.connect(1234, "localhost", ar -> { if (ar.succeeded()) { ar.result().handler(buffer -> System.out.println(buffer)); } else {/*from w w w . jav a 2 s .c o m*/ System.err.println("Woops: " + ar.cause().getMessage()); } }); }
From source file:examples.NetExamples.java
License:Open Source License
public void example50(Vertx vertx) throws CertificateException { SelfSignedCertificate certificate = SelfSignedCertificate.create(); vertx.createHttpServer(new HttpServerOptions().setSsl(true).setKeyCertOptions(certificate.keyCertOptions()) .setTrustOptions(certificate.trustOptions())).requestHandler(req -> req.response().end("Hello!")) .listen(8080);//from ww w .ja v a 2s . c om }