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.Toggleable
Configuration properties for SSL handling.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SslConfiguration.KeyConfiguration
Configuration properties for SSL key.static class
SslConfiguration.KeyStoreConfiguration
Configuration properties for SSL key store.static class
SslConfiguration.TrustStoreConfiguration
Configuration properties for SSL trust store.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
buildSelfSigned
static boolean
DEFAULT_BUILDSELFSIGNED
The default build self signed value.static boolean
DEFAULT_ENABLED
The default enable value.static int
DEFAULT_PORT
The default port value.static java.lang.String
DEFAULT_PROTOCOL
The default protocol.protected int
port
static java.lang.String
PREFIX
The 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 boolean
buildSelfSigned()
java.util.Optional<java.lang.String[]>
getCiphers()
java.util.Optional<ClientAuthentication>
getClientAuthentication()
java.time.Duration
getHandshakeTimeout()
SslConfiguration.KeyConfiguration
getKey()
SslConfiguration.KeyStoreConfiguration
getKeyStore()
int
getPort()
java.util.Optional<java.lang.String>
getProtocol()
java.util.Optional<java.lang.String[]>
getProtocols()
SslConfiguration.TrustStoreConfiguration
getTrustStore()
boolean
isEnabled()
protected void
readExisting(SslConfiguration defaultSslConfiguration, SslConfiguration.KeyConfiguration defaultKeyConfiguration, SslConfiguration.KeyStoreConfiguration defaultKeyStoreConfiguration, SslConfiguration.TrustStoreConfiguration defaultTrustStoreConfiguration)
Reads an existing config.void
setBuildSelfSigned(boolean buildSelfSigned)
Deprecated.Please usemicronaut.server.ssl.build-self-signed
instead (buildSelfSigned()
).void
setCiphers(java.lang.String[] ciphers)
Sets the ciphers to use.void
setClientAuthentication(ClientAuthentication clientAuthentication)
Sets the client authentication mode.void
setEnabled(boolean enabled)
Whether SSL is enabled.void
setHandshakeTimeout(java.time.Duration handshakeTimeout)
void
setKey(SslConfiguration.KeyConfiguration key)
Sets the key configuration.void
setKeyStore(SslConfiguration.KeyStoreConfiguration keyStore)
Sets the keystore configuration.void
setPort(int port)
Deprecated.Please usemicronaut.server.ssl.port
instead (ServerSslConfiguration.setPort(int)
).void
setProtocol(java.lang.String protocol)
Sets the protocol to use.void
setProtocols(java.lang.String[] protocols)
Sets the protocols to use.void
setTrustStore(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:
isEnabled
in 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.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 usemicronaut.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(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
-
-