Class SslConfiguration

java.lang.Object
io.micronaut.http.ssl.SslConfiguration
All Implemented Interfaces:
Toggleable
Direct Known Subclasses:
AbstractClientSslConfiguration, DefaultSslConfiguration, ServerSslConfiguration

public class SslConfiguration extends Object implements Toggleable
Configuration properties for SSL handling.
Since:
1.0
Author:
James Kleeh
  • Field Details

    • PREFIX

      public static final String PREFIX
      The prefix used to resolve this configuration.
      See Also:
    • DEFAULT_ENABLED

      public static final boolean DEFAULT_ENABLED
      The default enable value.
      See Also:
    • DEFAULT_PORT

      public static final int DEFAULT_PORT
      The default port value.
      See Also:
    • DEFAULT_BUILDSELFSIGNED

      public static final boolean DEFAULT_BUILDSELFSIGNED
      The default build self signed value.
      See Also:
    • DEFAULT_PROTOCOL

      public static final String DEFAULT_PROTOCOL
      The default protocol.
      See Also:
    • port

      protected int port
    • buildSelfSigned

      protected boolean buildSelfSigned
  • Constructor Details

    • SslConfiguration

      public SslConfiguration()
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface Toggleable
      Returns:
      Whether SSL is enabled.
    • setEnabled

      public void setEnabled(boolean enabled)
      Whether SSL is enabled. Default value (false).
      Parameters:
      enabled - True if SSL is enabled
    • getPort

      public int getPort()
      Returns:
      The default SSL port
    • buildSelfSigned

      public boolean buildSelfSigned()
      Returns:
      Whether to build a self-signed certificate
    • getClientAuthentication

      public Optional<ClientAuthentication> getClientAuthentication()
      Returns:
      The type of client authentication
    • getCiphers

      public Optional<String[]> getCiphers()
      Returns:
      Which SSL ciphers to use
    • getProtocols

      public Optional<String[]> getProtocols()
      Returns:
      Which protocols to use
    • getKey

      Returns:
      The configuration for the key
    • getKeyStore

      Returns:
      The configuration for the key store
    • getTrustStore

      Returns:
      The configuration for the trust store
    • getProtocol

      public Optional<String> getProtocol()
      Returns:
      The protocol to use
    • getHandshakeTimeout

      @NonNull public @NonNull Duration getHandshakeTimeout()
      Returns:
      The timeout for the SSL handshake
    • setPort

      @Deprecated public void setPort(int port)
      Deprecated.
      Please use micronaut.server.ssl.port instead (ServerSslConfiguration.setPort(int)).
      Sets the SSL port. Default value (8443).
      Parameters:
      port - The port
    • setBuildSelfSigned

      @Deprecated public void setBuildSelfSigned(boolean buildSelfSigned)
      Deprecated.
      Please use micronaut.server.ssl.build-self-signed instead (buildSelfSigned()).
      Sets whether to build a self-signed certificate. Default value (false).
      Parameters:
      buildSelfSigned - True if a certificate should be built
    • setKey

      public void setKey(SslConfiguration.KeyConfiguration key)
      Sets the key configuration.
      Parameters:
      key - The key configuration
    • setKeyStore

      public void setKeyStore(SslConfiguration.KeyStoreConfiguration keyStore)
      Sets the keystore configuration.
      Parameters:
      keyStore - The keystore configuration
    • setTrustStore

      public void setTrustStore(SslConfiguration.TrustStoreConfiguration trustStore)
      Sets the trust store configuration.
      Parameters:
      trustStore - The trust store.
    • setClientAuthentication

      public void setClientAuthentication(ClientAuthentication clientAuthentication)
      Sets the client authentication mode.
      Parameters:
      clientAuthentication - The client authentication mode
    • setCiphers

      public void setCiphers(String[] ciphers)
      Sets the ciphers to use.
      Parameters:
      ciphers - The ciphers
    • setProtocols

      public void setProtocols(String[] protocols)
      Sets the protocols to use.
      Parameters:
      protocols - The protocols
    • setProtocol

      public void setProtocol(String protocol)
      Sets the protocol to use. Default value ("TLS").
      Parameters:
      protocol - The protocol
    • setHandshakeTimeout

      public void setHandshakeTimeout(@NonNull @NonNull Duration handshakeTimeout)
      Parameters:
      handshakeTimeout - The timeout for the SSL handshake
    • isPreferOpenssl

      public boolean isPreferOpenssl()
      Whether an OpenSSL-backed TLS implementation should be preferred if it's on the classpath. true by default.
      Returns:
      Whether OpenSSL should be preferred
    • setPreferOpenssl

      public void setPreferOpenssl(boolean preferOpenssl)
      Whether an OpenSSL-backed TLS implementation should be preferred if it's on the classpath. true by default.
      Parameters:
      preferOpenssl - Whether OpenSSL should be preferred
    • readExisting

      protected final void readExisting(SslConfiguration defaultSslConfiguration, SslConfiguration.KeyConfiguration defaultKeyConfiguration, SslConfiguration.KeyStoreConfiguration defaultKeyStoreConfiguration, SslConfiguration.TrustStoreConfiguration defaultTrustStoreConfiguration)
      Reads an existing config.
      Parameters:
      defaultSslConfiguration - The default SSL config
      defaultKeyConfiguration - The default key config
      defaultKeyStoreConfiguration - The default keystore config
      defaultTrustStoreConfiguration - The Default truststore config