Class TlsOptions
ListenerOptions.Builder.tls(TlsOptions). A
listener with TLS options speaks HTTPS and nothing else on its port; a client that sends plain
text is disconnected.
Key material comes from exactly one source: a PEM certificate chain file and an
unencrypted PKCS#8 PEM private key file (pem(Path, Path)), or an SSLContext
supplier (TlsOptions.Builder.sslContext(Supplier)) for keys that live in a keystore, a hardware
module or a secret manager. Material is validated when the listener starts, so a missing file, a
malformed PEM, a key that does not match the certificate or an expired certificate stops startup
with a TlsConfigurationException and never prints key content. The files are read once at
startup and again by Server.reloadTls() or the optional polling (see TlsOptions.Builder.reloadInterval(Duration)); a reload swaps the material for new connections atomically
and leaves open connections alone. A reload that fails keeps the previous material.
Protocols and ciphers. TLS 1.2 is the default minimum and TLS 1.3 is used whenever the
client supports it. Only forward-secret authenticated-encryption suites are enabled by default
(see DEFAULT_CIPHER_SUITES). The listener advertises ALPN http/1.1 only.
Client certificates are not requested by default. TlsOptions.Builder.requireClientCertificates(Path) turns on mutual TLS: a client without a certificate
issued by one of the trusted certificates is refused during the handshake.
Instances are immutable and may be shared by several listeners.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCollects settings beforeTlsOptions.Builder.build().static enumWhether the listener asks clients for a certificate.static enumThe protocols a listener can be limited to, oldest first. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe cipher suites enabled by default: TLS 1.3 suites and, for TLS 1.2, ECDHE key exchange with AES-GCM or ChaCha20-Poly1305. -
Method Summary
Modifier and TypeMethodDescriptionstatic TlsOptions.Builderbuilder()Starts a builder with every setting at its default and no key material.clock()static TlsOptionsOptions that serve a PEM certificate chain and private key with every other setting at its default.Starts a builder holding these options' values.toString()Describes the options without file names or key material.
-
Field Details
-
DEFAULT_CIPHER_SUITES
The cipher suites enabled by default: TLS 1.3 suites and, for TLS 1.2, ECDHE key exchange with AES-GCM or ChaCha20-Poly1305. Suites the JVM does not support are skipped.
-
-
Method Details
-
pem
Options that serve a PEM certificate chain and private key with every other setting at its default.- Parameters:
certificateChain- PEM file holding the server certificate first, then its issuersprivateKey- PEM file holding the matching unencrypted PKCS#8 private key- Returns:
- the options
- Throws:
NullPointerException- if a path is null
-
builder
Starts a builder with every setting at its default and no key material.- Returns:
- a new builder
-
toBuilder
Starts a builder holding these options' values.- Returns:
- a new builder
-
certificateChain
- Returns:
- the PEM certificate chain file, or empty when an SSL context supplier is used
-
privateKey
- Returns:
- the PEM private key file, or empty when an SSL context supplier is used
-
sslContext
- Returns:
- the SSL context supplier, or empty when PEM files are used
-
minimumProtocol
- Returns:
- the oldest TLS version a client may use
-
cipherSuites
- Returns:
- the enabled cipher suites in preference order
-
clientAuth
- Returns:
- whether clients must present a certificate
-
clientTrust
- Returns:
- the PEM file of certificates that client certificates must chain to, if any
-
reloadInterval
- Returns:
- how often the key files are checked for changes, or empty when they are not polled
-
clock
- Returns:
- the clock that decides whether a certificate is valid
-
toString
Describes the options without file names or key material.
-