TrustAnchors

sealed interface TrustAnchors

Which certificates a client is willing to trust for TLS.

useTls used to be the whole story, and with one engine and a JVM caller it was enough: anything unusual was reachable through configureClient, which hands back Ktor's HttpClientConfig<*>. A star projection cannot open an engine-specific block, so that escape hatch stopped working the day the transport went multiplatform — on three of the four targets it was never available at all.

The cases this exists for are ordinary. Qdrant Cloud serves a public certificate and needs nothing here. A self-hosted cluster behind a company CA, a staging node with a self-signed certificate, and anything that wants certificate pinning are all normal deployments, and all of them ended at "use the JVM".

Which store each platform reads

System is not one store. It is whichever store the platform keeps, and knowing which one is the difference between adding a certificate in the right place and adding it twice in the wrong ones:

TargetEngineSystem trust means
JVMCIOthe JDK's cacerts truststore
iOS, macOSDarwinthe system keychain, plus App Transport Security
LinuxCurlthe CA bundle libcurl was built against, usually /etc/ssl/certs
WindowsWinHttpthe machine and user certificate stores

What each platform supports

JVMLinuxiOS, macOSWindows
Systemyesyesyesyes
Pemyesyesnono
Pinnedyesnonono

A combination a target cannot honour is refused when the client is built, with a message naming the platform and the store to put the certificate in. Silently falling back to system trust would be the worst of the options: the connection would succeed, and the caller would believe they had pinned it.

Inheritors

Types

Link copied to clipboard
data class Pem(val certificates: String) : TrustAnchors

Trust exactly the certificates in a PEM bundle, and nothing else — the company CA, or the self-signed certificate a staging node serves.

Link copied to clipboard
data class Pinned(val sha256: Set<String>) : TrustAnchors

Trust a certificate only if the SHA-256 of its subject public key info matches one of sha256.

Link copied to clipboard
data object System : TrustAnchors

Whatever the platform trusts. The default, and correct for any publicly issued certificate.