Class PlccomMqttTlsOptions
- java.lang.Object
-
- com.plccom.mqtt.client.PlccomMqttTlsOptions
-
public final class PlccomMqttTlsOptions extends Object
TLS options formqtts://connections.The options are based on standard JDK TLS concepts so the client can be used in applications with simple default TLS needs as well as applications that authenticate with a client certificate. Expert callers can still build an
SSLContextwith their own trust and key material and pass it here.The broker certificate is checked against exactly one trust source: the
PKI options, aTrustStore, or an ownSSL context. Without any of them the PLCcom PKI store in thepkifolder of the working directory decides, so an unknown broker certificate is rejected; the trust store of the JVM is never used implicitly.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPlccomMqttTlsOptions.BuilderBuilder forPlccomMqttTlsOptions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PlccomMqttTlsOptions.Builderbuilder()Creates a TLS options builder.static PlccomMqttTlsOptionsdefaults()Returns default TLS options.String[]getEnabledCipherSuites()Returns the enabled TLS cipher suites.String[]getEnabledProtocols()Returns the enabled TLS protocol names.longgetHandshakeTimeoutMillis()Returns the TLS handshake timeout.HostnameVerifiergetHostnameVerifier()Returns the hostname verifier.PlccomMqttPkiOptionsgetPkiOptions()Returns the PLCcom file-based PKI options used for broker certificate validation.SSLContextgetSslContext()Returns the SSL context used for TLS sockets.booleanisHostnameVerificationEnabled()Returns whether TLS hostname verification is enabled.booleanisPkiTrustDecisionActive()Returns whether the PLCcom folder-based PKI store decides broker certificate trust for this configuration.
-
-
-
Method Detail
-
defaults
public static PlccomMqttTlsOptions defaults()
Returns default TLS options.They check the broker certificate against the PLCcom PKI store in the
pkifolder of the working directory, which is created at the first TLS connection; seegetPkiOptions().- Returns:
- default TLS options
-
builder
public static PlccomMqttTlsOptions.Builder builder()
Creates a TLS options builder.- Returns:
- builder
-
getSslContext
public SSLContext getSslContext()
Returns the SSL context used for TLS sockets.That is the context supplied with
PlccomMqttTlsOptions.Builder.sslContext(SSLContext), or a context created from the configured key material and trust settings. Without own trust settings it validates the broker certificate against the PLCcom PKI store in thepkifolder of the working directory; the trust store of the JVM is used only when it is passed asPlccomMqttTlsOptions.Builder.trustStore(KeyStore)or inside an own SSL context.- Returns:
- SSL context, never
null - Throws:
IllegalArgumentException- if the context cannot be created
-
getHostnameVerifier
public HostnameVerifier getHostnameVerifier()
Returns the hostname verifier.- Returns:
- custom verifier, or
nullto use the JDK default verifier
-
isHostnameVerificationEnabled
public boolean isHostnameVerificationEnabled()
Returns whether TLS hostname verification is enabled.- Returns:
truewhen the broker certificate name must match the endpoint host
-
getEnabledProtocols
public String[] getEnabledProtocols()
Returns the enabled TLS protocol names.- Returns:
- defensive copy of protocol names, or
nullto keep the JDK socket defaults
-
getEnabledCipherSuites
public String[] getEnabledCipherSuites()
Returns the enabled TLS cipher suites.- Returns:
- defensive copy of cipher suite names, or
nullto keep the JDK socket defaults
-
getHandshakeTimeoutMillis
public long getHandshakeTimeoutMillis()
Returns the TLS handshake timeout.- Returns:
- handshake timeout in milliseconds
-
getPkiOptions
public PlccomMqttPkiOptions getPkiOptions()
Returns the PLCcom file-based PKI options used for broker certificate validation.That are the options passed with
PlccomMqttTlsOptions.Builder.pkiOptions(PlccomMqttPkiOptions). Without them, and without aPlccomMqttTlsOptions.Builder.trustStore(KeyStore)or a readyPlccomMqttTlsOptions.Builder.sslContext(SSLContext), these are default options with the PKI store in thepkifolder of the working directory (PlccomMqttPkiStore.getDefaultBaseDirectory()): an unknown broker certificate is then rejected and recorded in its rejected folder. With a ready SSL context, configured PKI options are returned as well, but the context decides; seeisPkiTrustDecisionActive().- Returns:
- PKI options, or
nullwhen no PKI options are configured and a TrustStore or a ready SSL context decides
-
isPkiTrustDecisionActive
public boolean isPkiTrustDecisionActive()
Returns whether the PLCcom folder-based PKI store decides broker certificate trust for this configuration.That is the case when no ready
PlccomMqttTlsOptions.Builder.sslContext(SSLContext)was supplied and eitherPlccomMqttTlsOptions.Builder.pkiOptions(PlccomMqttPkiOptions)is configured or the default PKI store applies (seegetPkiOptions()), so the TrustManager created from the PKI options makes the trust decision. Per the PLCcom PKI trust rule a certificate that this decision accepts by store - the leaf lies in the trusted store, or it was issued by a certificate authority from the issuer store - is trusted as-is, so the default host-name verification must not veto it.- Returns:
truewhen the PLCcom PKI trust manager validates the broker certificate
-
-