Package io.micronaut.http.ssl
Class SslConfiguration
- java.lang.Object
-
- io.micronaut.http.ssl.SslConfiguration
-
- All Implemented Interfaces:
io.micronaut.core.util.Toggleable
- Direct Known Subclasses:
AbstractClientSslConfiguration,DefaultSslConfiguration,ServerSslConfiguration
public class SslConfiguration extends java.lang.Object implements io.micronaut.core.util.ToggleableConfiguration properties for SSL handling.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSslConfiguration.KeyConfigurationConfiguration properties for SSL key.static classSslConfiguration.KeyStoreConfigurationConfiguration properties for SSL key store.static classSslConfiguration.TrustStoreConfigurationConfiguration properties for SSL trust store.
-
Field Summary
Fields Modifier and Type Field Description protected booleanbuildSelfSignedstatic booleanDEFAULT_BUILDSELFSIGNEDThe default build self signed value.static booleanDEFAULT_ENABLEDThe default enable value.static intDEFAULT_PORTThe default port value.static java.lang.StringDEFAULT_PROTOCOLThe default protocol.protected intportstatic java.lang.StringPREFIXThe prefix used to resolve this configuration.
-
Constructor Summary
Constructors Constructor Description SslConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanbuildSelfSigned()java.util.Optional<java.lang.String[]>getCiphers()java.util.Optional<ClientAuthentication>getClientAuthentication()java.time.DurationgetHandshakeTimeout()SslConfiguration.KeyConfigurationgetKey()SslConfiguration.KeyStoreConfigurationgetKeyStore()intgetPort()java.util.Optional<java.lang.String>getProtocol()java.util.Optional<java.lang.String[]>getProtocols()SslConfiguration.TrustStoreConfigurationgetTrustStore()booleanisEnabled()protected voidreadExisting(SslConfiguration defaultSslConfiguration, SslConfiguration.KeyConfiguration defaultKeyConfiguration, SslConfiguration.KeyStoreConfiguration defaultKeyStoreConfiguration, SslConfiguration.TrustStoreConfiguration defaultTrustStoreConfiguration)Reads an existing config.voidsetBuildSelfSigned(boolean buildSelfSigned)Deprecated.Please usemicronaut.server.ssl.build-self-signedinstead (buildSelfSigned()).voidsetCiphers(java.lang.String[] ciphers)Sets the ciphers to use.voidsetClientAuthentication(ClientAuthentication clientAuthentication)Sets the client authentication mode.voidsetEnabled(boolean enabled)Whether SSL is enabled.voidsetHandshakeTimeout(java.time.Duration handshakeTimeout)voidsetKey(SslConfiguration.KeyConfiguration key)Sets the key configuration.voidsetKeyStore(SslConfiguration.KeyStoreConfiguration keyStore)Sets the keystore configuration.voidsetPort(int port)Deprecated.Please usemicronaut.server.ssl.portinstead (ServerSslConfiguration.setPort(int)).voidsetProtocol(java.lang.String protocol)Sets the protocol to use.voidsetProtocols(java.lang.String[] protocols)Sets the protocols to use.voidsetTrustStore(SslConfiguration.TrustStoreConfiguration trustStore)Sets the trust store configuration.
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
The prefix used to resolve this configuration.- See Also:
- Constant Field Values
-
DEFAULT_ENABLED
public static final boolean DEFAULT_ENABLED
The default enable value.- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final int DEFAULT_PORT
The default port value.- See Also:
- Constant Field Values
-
DEFAULT_BUILDSELFSIGNED
public static final boolean DEFAULT_BUILDSELFSIGNED
The default build self signed value.- See Also:
- Constant Field Values
-
DEFAULT_PROTOCOL
public static final java.lang.String DEFAULT_PROTOCOL
The default protocol.- See Also:
- Constant Field Values
-
port
protected int port
-
buildSelfSigned
protected boolean buildSelfSigned
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfaceio.micronaut.core.util.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 or not to build a self signed certificate
-
getClientAuthentication
public java.util.Optional<ClientAuthentication> getClientAuthentication()
- Returns:
- The type of client authentication
-
getCiphers
public java.util.Optional<java.lang.String[]> getCiphers()
- Returns:
- Which SSL ciphers to use
-
getProtocols
public java.util.Optional<java.lang.String[]> getProtocols()
- Returns:
- Which protocols to use
-
getKey
public SslConfiguration.KeyConfiguration getKey()
- Returns:
- The configuration for the key
-
getKeyStore
public SslConfiguration.KeyStoreConfiguration getKeyStore()
- Returns:
- The configuration for the key store
-
getTrustStore
public SslConfiguration.TrustStoreConfiguration getTrustStore()
- Returns:
- The configuration for the trust store
-
getProtocol
public java.util.Optional<java.lang.String> getProtocol()
- Returns:
- The protocol to use
-
getHandshakeTimeout
@NonNull public java.time.Duration getHandshakeTimeout()
- Returns:
- The timeout for the SSL handshake
-
setPort
@Deprecated public void setPort(int port)
Deprecated.Please usemicronaut.server.ssl.portinstead (ServerSslConfiguration.setPort(int)).Sets the SSL port. Default value (8443).- Parameters:
port- The port
-
setBuildSelfSigned
@Deprecated public void setBuildSelfSigned(boolean buildSelfSigned)
Deprecated.Please usemicronaut.server.ssl.build-self-signedinstead (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(java.lang.String[] ciphers)
Sets the ciphers to use.- Parameters:
ciphers- The ciphers
-
setProtocols
public void setProtocols(java.lang.String[] protocols)
Sets the protocols to use.- Parameters:
protocols- The protocols
-
setProtocol
public void setProtocol(java.lang.String protocol)
Sets the protocol to use. Default value ("TLS").- Parameters:
protocol- The protocol
-
setHandshakeTimeout
public void setHandshakeTimeout(@NonNull java.time.Duration handshakeTimeout)- Parameters:
handshakeTimeout- The timeout for the SSL handshake
-
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 configdefaultKeyConfiguration- The default key configdefaultKeyStoreConfiguration- The default keystore configdefaultTrustStoreConfiguration- The Default truststore config
-
-