Package io.vertx.core.net

## Class PemTrustOptions

- java.lang.Object
- - io.vertx.core.net.PemTrustOptions

- All Implemented Interfaces:
    `TrustOptions`, `Cloneable`

      public class PemTrustOptions
      extends Object
      implements TrustOptions, Cloneable

  Certificate Authority options configuring certificates based on Privacy-enhanced Electronic Email (PEM) files. The options is configured with a list of validating certificates.

  Validating certificates must contain X.509 certificates wrapped in a PEM block:

       -----BEGIN CERTIFICATE-----
       MIIDezCCAmOgAwIBAgIEVmLkwTANBgkqhkiG9w0BAQsFADBuMRAwDgYDVQQGEwdV
       ...
       z5+DuODBJUQst141Jmgq8bS543IU/5apcKQeGNxEyQ==
       -----END CERTIFICATE-----

  The certificates can either be loaded by Vert.x from the filesystem:

       HttpServerOptions options = new HttpServerOptions();
       options.setPemTrustOptions(new PemTrustOptions().addCertPath("/cert.pem"));

  Or directly provided as a buffer:

       Buffer cert = vertx.fileSystem().readFileBlocking("/cert.pem");
       HttpServerOptions options = new HttpServerOptions();
       options.setPemTrustOptions(new PemTrustOptions().addCertValue(cert));

  Author:
    Julien Viet, Tim Fox

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `PemTrustOptions()` | Default constructor
    `PemTrustOptions​(JsonObject json)` | Create options from JSON
    `PemTrustOptions​(PemTrustOptions other)` | Copy constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `PemTrustOptions` | `addCertPath​(String certPath)` | Add a certificate path
    `PemTrustOptions` | `addCertValue​(Buffer certValue)` | Add a certificate value
    `PemTrustOptions` | `copy()` |
    `boolean` | `equals​(Object obj)` |
    `List<String>` | `getCertPaths()` |
    `List<Buffer>` | `getCertValues()` |
    `io.vertx.core.net.impl.KeyStoreHelper` | `getHelper​(Vertx vertx)` |
    `TrustManagerFactory` | `getTrustManagerFactory​(Vertx vertx)` | Create and return the trust manager factory for these options.
    `int` | `hashCode()` |
    `KeyStore` | `loadKeyStore​(Vertx vertx)` | Load and return a Java keystore.
    `JsonObject` | `toJson()` | Convert to JSON
    `Function<String,​TrustManager[]>` | `trustManagerMapper​(Vertx vertx)` | Returns a function that maps SNI server names to a `TrustManagerFactory` instance.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PemTrustOptions

          public PemTrustOptions()

      Default constructor

    - #### PemTrustOptions

          public PemTrustOptions​(PemTrustOptions other)

      Copy constructor
      Parameters:
        `other` - the options to copy

    - #### PemTrustOptions

          public PemTrustOptions​(JsonObject json)

      Create options from JSON
      Parameters:
        `json` - the JSON

  - ### Method Detail

    - #### toJson

          public JsonObject toJson()

      Convert to JSON
      Returns:
        the JSON

    - #### getCertPaths

          public List<String> getCertPaths()

      Returns:
        the certificate paths used to locate certificates

    - #### addCertPath

          public PemTrustOptions addCertPath​(String certPath)
                                      throws NullPointerException

      Add a certificate path
      Parameters:
        `certPath` - the path to add
      Returns:
        a reference to this, so the API can be used fluently
      Throws:
        `NullPointerException`

    - #### getCertValues

          public List<Buffer> getCertValues()

      Returns:
        the certificate values

    - #### addCertValue

          public PemTrustOptions addCertValue​(Buffer certValue)
                                       throws NullPointerException

      Add a certificate value
      Parameters:
        `certValue` - the value to add
      Returns:
        a reference to this, so the API can be used fluently
      Throws:
        `NullPointerException`

    - #### loadKeyStore

          public KeyStore loadKeyStore​(Vertx vertx)
                                throws Exception

      Load and return a Java keystore.
      Parameters:
        `vertx` - the vertx instance
      Returns:
        the `KeyStore`
      Throws:
        `Exception`

    - #### getTrustManagerFactory

          public TrustManagerFactory getTrustManagerFactory​(Vertx vertx)
                                                     throws Exception

      Description copied from interface: `TrustOptions`
      Create and return the trust manager factory for these options.

      The returned trust manager factory should be already initialized and ready to use.

      Specified by:
        `getTrustManagerFactory` in interface `TrustOptions`
      Parameters:
        `vertx` - the vertx instance
      Returns:
        the trust manager factory
      Throws:
        `Exception`

    - #### trustManagerMapper

          public Function<String,​TrustManager[]> trustManagerMapper​(Vertx vertx)
                                                                   throws Exception

      Description copied from interface: `TrustOptions`
      Returns a function that maps SNI server names to a `TrustManagerFactory` instance. The returned `TrustManagerFactory` must already be initialized and ready to use. The mapper is only used when the server has SNI enabled and the client indicated a server name.

      The returned function may return `null` in which case `TrustOptions.getTrustManagerFactory(Vertx)` is used as fallback.
      Specified by:
        `trustManagerMapper` in interface `TrustOptions`
      Parameters:
        `vertx` - the vertx instance
      Returns:
        the trustManager
      Throws:
        `Exception`

    - #### equals

          public boolean equals​(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### copy

          public PemTrustOptions copy()

      Specified by:
        `copy` in interface `TrustOptions`
      Returns:
        a copy of these options

    - #### getHelper

          public io.vertx.core.net.impl.KeyStoreHelper getHelper​(Vertx vertx)
                                                          throws Exception

      Throws:
        `Exception`