TlsTrust

data class TlsTrust(val trustRoots: TlsTrust.TrustRoots = TrustRoots.SystemDefault, val verifyHostname: Boolean = true)

Which certificates to trust when connecting to a participant over TLS.

Mobile clients roam onto networks where TLS interception is a real possibility — a corporate proxy or a debugging proxy whose CA the device already trusts will otherwise be accepted like any other. Pinning the trust anchors to the operator's own CA rejects those, because the intercepting certificate does not chain to it.

The default is TrustRoots.SystemDefault: the platform's trust store, which on Android also means the app's Network Security Config — often the better place to pin on Android, since a network_security_config.xml covers every connection the app makes, not only the Ledger API.

Pin certificate authorities, not leaves. Leaf certificates rotate (every 90 days with Let's Encrypt) and a wallet talks to validators whose rotation schedule it does not control, so a leaf pin is an outage waiting for a renewal. This type deliberately offers no way to express one.

val operatorCa = context.assets.open("operator-ca.der").readBytes()
CantonClientConfiguration(
host = "validator.example.com",
tlsTrust = TlsTrust(TlsTrust.TrustRoots.Certificates(listOf(operatorCa))),
)

Constructors

Link copied to clipboard
constructor(trustRoots: TlsTrust.TrustRoots = TrustRoots.SystemDefault, verifyHostname: Boolean = true)

Types

Link copied to clipboard
sealed interface TrustRoots

The set of trust anchors; the two cases are the platform store or an explicit CA list, by design nothing finer.

Properties

Link copied to clipboard

the anchors a server certificate must chain to.

Link copied to clipboard

whether the certificate must also match the host being connected to. Leave this on: turning it off accepts any certificate the pinned CA ever issued, for any name. It exists for self-signed deployment certificates issued without a matching SAN.

Functions

Link copied to clipboard

An X509TrustManager enforcing trustRoots, or null to keep the platform default. Used for the Ledger API channel; the wallet SDK's okHttpClient extension builds on it so the off-ledger REST clients can be given the same anchors.