Class TlsOptions

java.lang.Object
codes.grow.packages.betterstack.core.TlsOptions

public final class TlsOptions extends Object
TLS settings: custom CA, client certificate (mutual TLS) and the test-only insecureSkipVerify. PEM files are read once when the client is created. Private keys must be unencrypted PKCS#8 (BEGIN PRIVATE KEY); RSA, EC and EdDSA keys are supported.
  • Method Details

    • defaults

      public static TlsOptions defaults()
      Returns options without any customisation (system trust store).
      Returns:
      default options
    • builder

      public static TlsOptions.Builder builder()
      Starts a builder.
      Returns:
      a new builder
    • toBuilder

      public TlsOptions.Builder toBuilder()
      Returns a builder initialised from these options.
      Returns:
      a new builder
    • caCertPath

      public Optional<Path> caCertPath()
      Returns the CA bundle path.
      Returns:
      the path, or empty
    • caCertPem

      public Optional<String> caCertPem()
      Returns the inline CA bundle.
      Returns:
      PEM text, or empty
    • clientCertPath

      public Optional<Path> clientCertPath()
      Returns the client certificate path.
      Returns:
      the path, or empty
    • clientKeyPath

      public Optional<Path> clientKeyPath()
      Returns the client key path.
      Returns:
      the path, or empty
    • insecureSkipVerify

      public boolean insecureSkipVerify()
      Returns whether certificate and host name verification is disabled (tests only).
      Returns:
      true when verification is off
    • isCustom

      public boolean isCustom()
      Returns whether any option differs from the system defaults.
      Returns:
      true when a custom SSL context is needed
    • validate

      public void validate()
      Checks that certificate and key come together.
      Throws:
      ConfigException - when only one of them is set
    • sslContext

      public SSLContext sslContext()
      Builds the SSL context for these options.
      Returns:
      a new SSL context
      Throws:
      ConfigException - when a file cannot be read or parsed (the message names the setting, never the content)
    • toString

      public String toString()
      Overrides:
      toString in class Object