Example usage for io.vertx.mysqlclient SslMode VERIFY_CA

List of usage examples for io.vertx.mysqlclient SslMode VERIFY_CA

Introduction

In this page you can find the example usage for io.vertx.mysqlclient SslMode VERIFY_CA.

Prototype

SslMode VERIFY_CA

To view the source code for io.vertx.mysqlclient SslMode VERIFY_CA.

Click Source Link

Document

Like REQUIRED, but additionally verify the server Certificate Authority (CA) certificate against the configured CA certificates.

Usage

From source file:examples.MySQLClientExamples.java

public void tlsExample(Vertx vertx) {

    MySQLConnectOptions options = new MySQLConnectOptions().setPort(3306).setHost("the-host")
            .setDatabase("the-db").setUser("user").setPassword("secret").setSslMode(SslMode.VERIFY_CA)
            .setPemTrustOptions(new PemTrustOptions().addCertPath("/path/to/cert.pem"));

    MySQLConnection.connect(vertx, options, res -> {
        if (res.succeeded()) {
            // Connected with SSL
        } else {//w  ww.j  a  v a 2s.  c om
            System.out.println("Could not connect " + res.cause());
        }
    });
}