Example usage for io.vertx.pgclient SslMode VERIFY_CA

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

Introduction

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

Prototype

SslMode VERIFY_CA

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

Click Source Link

Document

only try an SSL connection, and verify that the server certificate is issued by a trusted certificate authority (CA).

Usage

From source file:examples.PgClientExamples.java

License:Apache License

public void ex10(Vertx vertx) {

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

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