Skip to content

URL endpoint listener and TLS identities for Linux and Windows - #73

Open
jeffdgr8 wants to merge 4 commits into
multipeerfrom
native-url-listener
Open

URL endpoint listener and TLS identities for Linux and Windows#73
jeffdgr8 wants to merge 4 commits into
multipeerfrom
native-url-listener

Conversation

@jeffdgr8

Copy link
Copy Markdown
Owner

The Couchbase Lite C SDK added URL-endpoint-listener and TLS-identity support in 4.x. Replaces Kotbase's pre-4.x "not supported in CBL C SDK" stubs on Linux and Windows with real implementations:

  • TLSIdentity: DER certificate chains, expiration, and label-based create/get/delete. Windows persists identities in the CNG Key Storage Provider; Linux has no standard secure key storage and the C SDK compiles the label-lookup functions out there, so getIdentity/deleteIdentity throw UNSUPPORTED (honest per-OS behavior, per the header)
  • TLSIdentity.createAnonymousIdentity (new public API, linux/mingw): self-signed, non-persisted identities — the only way to construct an identity on Linux
  • TLSIdentity.createIdentityWithKeyPairAndCerts (new public API, linux/mingw): CA-issued identities from an existing private key + certificate chain, giving native platforms parity with JVM (KeyStore), Apple (importIdentity), and Android (AndroidKeyStore)
  • URLEndpointListener + configuration, password and certificate authenticators (C callbacks dispatching to Kotlin delegates), and a real ClientCertificateAuthenticator
  • MessageEndpoint remains stubbed (still no C SDK API)

Also aligns minor APIs with the 4.1 SDKs: removes the orphaned Defaults.Database.MMAP_ENABLED, adds isEmpty to Array/Dictionary/Document/Result, and makes level/domains/logSink public on the console and custom log sinks.

The common TLSIdentityTest now runs on Windows; a new URLEndpointListenerNativeTest covers config validation, listener lifecycle, authenticators, and TLS with anonymous and CA-issued identities. Verified by compiling and linking the linuxX64/mingwX64 test binaries — runtime verification needs the Linux/Windows CI hosts.

🤖 Generated with Claude Code

jeffdgr8 and others added 4 commits July 10, 2026 21:25
The Couchbase Lite C SDK added URL-endpoint-listener and TLS-identity
support in 4.x. Replaces the pre-4.x "not supported in CBL C SDK"
stubs in the EE linuxMingw source set with real implementations:

- TLSIdentity backed by CBLTLSIdentity: DER certificate chains,
  expiration, and label-based create/get/delete. Windows persists
  identities via the platform key store; Linux has no standard secure
  key storage and the C SDK compiles the label-lookup functions out
  there, so getIdentity/deleteIdentity throw
  CouchbaseLiteException(UNSUPPORTED) on Linux (new linuxMain and
  mingwMain actual splits). Certificate attributes are translated
  from the Java-style attribute names to the C kCBLCertAttrKey keys.
- KeyUsage maps to the CBLKeyUsages bitmask
- ListenerPasswordAuthenticator and ListenerCertificateAuthenticator
  via CBLListenerAuth callbacks (StableRef-dispatched delegates;
  root-cert chains built from concatenated PEM)
- ClientCertificateAuthenticator via CBLAuth_CreateCertificate
- URLEndpointListenerConfiguration snapshots into the C struct
  following the ImmutableReplicatorConfiguration pattern
- URLEndpointListener: create/start/stop, port, urls, status,
  tlsIdentity, config

MessageEndpoint remains stubbed: the C SDK still has no
message-endpoint API.

Tests: the common TLSIdentityTest now runs on Windows (still skipped
on Linux, where label persistence is genuinely unsupported); a new
URLEndpointListenerNativeTest covers config validation, listener
lifecycle with password/certificate auth, TLS with explicit and
auto-generated anonymous identities, and the Linux unsupported
behavior. Verified by compiling and linking the linuxX64/mingwX64
test binaries (test execution requires Linux/Windows hosts); JVM,
macOS, and Android are unaffected; apiCheck passes (the stub-era
public no-arg TLSIdentity constructor is now internal).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
TLSIdentity.createAnonymousIdentity creates a self-signed,
non-persisted identity via CBLTLSIdentity_CreateIdentity with a null
label. This is the only way to construct a TLSIdentity on Linux
(no secure key storage for alias-based identities, and the C SDK's
key-pair-based constructors would require wrapping CBLKeyPair) —
without it, ClientCertificateAuthenticator could not be used there.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds TLSIdentity.createIdentityWithKeyPairAndCerts, wrapping
CBLKeyPair_CreateWithPrivateKeyData (PEM or DER, optional password)
and CBLTLSIdentity_IdentityWithKeyPairAndCerts. This is the native
platforms' bring-your-own-identity path, giving them parity with the
JVM (KeyStore), Apple (importIdentity), and Android (AndroidKeyStore)
platforms: a URLEndpointListener can present a CA-signed server
certificate and a ClientCertificateAuthenticator can use an issued
client certificate, instead of self-signed identities only.

The CBLKeyPair and CBLCert types remain unexposed: certificates stay
ByteArray, kotbase's cross-platform convention. External-key
(HSM/TPM) key pairs via CBLKeyPair_CreateWithExternalKey are left as
a possible future addition.

Tests use an embedded self-signed PEM fixture (plain and encrypted
key) and verify identity creation, listener use, wrong-password
failure, and input validation. Verified by compile and link for
linuxX64/mingwX64; runtime verification on Linux/Windows CI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Remove Defaults.Database.MMAP_ENABLED: the mmap configuration API
  was removed in CBL 4.0 and the constant no longer has a use
- Add isEmpty to ArrayInterface and DictionaryInterface (inherited by
  Array, Dictionary, Document, and their mutable variants) and Result,
  matching the Java SDK
- Make level and domains public on ConsoleLogSink and CustomLogSink,
  and logSink public on CustomLogSink, matching the public accessors
  of the Java and Objective-C SDKs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant