Skip to content

feat(kernel): support mTLS client certificates - #456

Merged
sreekanth-db merged 1 commit into
mainfrom
feat/kernel-mtls-client-certificate
Aug 24, 2026
Merged

sreekanth-db merged 1 commit into
mainfrom
feat/kernel-mtls-client-certificate

Conversation

@sreekanth-db

Copy link
Copy Markdown
Collaborator

Summary

  • add experimental kernel-only WithKernelClientCertificate(certPEM, keyPEM) configuration
  • validate the identity fail-closed, defensively copy both PEM buffers, and forward them through the kernel C ABI
  • pin the merged kernel mTLS C-ABI implementation from databricks-sql-kernel#289
  • add unit, real-cgo, and hermetic Go → C ABI → Rust → TLS handshake coverage
  • document the option in README, GoDoc, connection parameters, and the changelog

Motivation

The default Thrift backend can use mTLS through a caller-supplied WithTransport, but the kernel backend owns a separate Rust HTTP stack and rejects custom Go transports. The Rust kernel already supports client identities through its core, PyO3, and N-API surfaces; kernel PR #289 added the paired C-ABI setter required by Go.

API and behavior

WithKernelClientCertificate(certPEM, keyPEM []byte)
  • both values are mandatory and must be non-empty
  • the certificate may contain the leaf followed by intermediate certificates
  • the key must be unencrypted; PKCS#8 is recommended across kernel TLS backends
  • both byte slices are copied when the option is applied and when connection config is deep-copied
  • an explicit empty pair remains distinguishable from an unset option and returns an error wrapping ErrInvalidKernelConfig
  • the default Thrift backend rejects the option with ErrRequiresKernelBackend rather than silently ignoring it
  • server chain and hostname verification remain strict and independently configurable
  • no cert/key DSN representation is added, avoiding private-key material in connection strings

The kernel builds one shared TLS-configured HTTP client, so the identity is available to kernel-owned SEA requests, OAuth discovery/token exchange, and CloudFetch. A certificate is presented only when the remote TLS server requests one.

Kernel dependency

KERNEL_REV now pins merged kernel commit e8d60c93b7459947d2e3e4113f62e6bda37fde8e, which exports:

kernel_session_config_set_tls_client_certificate(...)

The kernel PR provides native-TLS and rustls handshake coverage for valid, missing, and wrong-CA client identities.

Testing

Configuration and validation

Focused untagged tests cover:

  • option-to-config wiring
  • defensive copies of certificate and key
  • per-connection deep-copy isolation
  • complete identity acceptance
  • cert-only, key-only, and explicit empty-pair rejection as ErrInvalidKernelConfig
  • kernel config forwarding
  • Thrift-path rejection
  • experimental-field exhaustiveness classification

Results:

  • focused root configuration tests — 62 passed
  • internal/config deep-copy tests — 5 passed

Real C-ABI invocation

The tagged backend test constructs real kernel session configs and calls the linked setter through cgo for:

  • mTLS identity alone
  • mTLS combined with custom CA and hostname controls
  • existing TLS-only/no-op cases

Result: 6 passed.

Hermetic transport E2E

kernel_mtls_test.go generates a private CA plus server/client identities at runtime and starts a local HTTPS probe. It drives:

Go option → Go config → cgo → kernel C ABI → Rust reqwest/rustls → TLS server

It verifies:

  • configured client identity completes the handshake and is observed by the server
  • with the option unset, no client certificate is presented
  • server trust is configured independently with WithKernelTrustedCerts

The test uses one synchronous connector attempt, requires no warehouse credentials, and runs in regular kernel-tagged PR CI through make test-kernel.

Results against the final merged kernel pin:

  • 25 repeated E2E runs — 75 assertions passed
  • focused tagged go vet — passed
  • git diff --check — passed
  • Isaac uncommitted review — 0 actionable findings across all 15 changed files

No live warehouse mTLS claim is made because the available Databricks test warehouse does not require client certificates; the hermetic server is the client-certificate enforcement endpoint.

Expose a fail-closed kernel client-certificate option and forward the paired identity through the merged kernel C ABI, with hermetic handshake coverage.

Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@sreekanth-db
sreekanth-db enabled auto-merge August 24, 2026 23:34
@sreekanth-db
sreekanth-db added this pull request to the merge queue Aug 24, 2026
Merged via the queue into main with commit 0398e42 Aug 24, 2026
11 of 12 checks passed
@sreekanth-db
sreekanth-db deleted the feat/kernel-mtls-client-certificate branch August 24, 2026 23:41
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