Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
adcfece
feat(tls): opt-in certificate revocation checking
cathleeny Nov 19, 2026
9063fc6
feat(bindings): expose TLS certificate revocation in pyo3 and napi
cathleeny Nov 19, 2026
ba7eec2
fix(tls): address review findings in certificate revocation
cathleeny Nov 19, 2026
cfc6479
fix(tls): address second review round for certificate revocation
cathleeny Nov 19, 2026
d96afd7
test(tls): cover redacted() and the intermediate cap
cathleeny Nov 19, 2026
9129076
fix(tls): address round-five review findings for certificate revocation
cathleeny Nov 19, 2026
1c9af8b
fix(tls): address round-six review findings for certificate revocation
cathleeny Nov 19, 2026
55dd9d5
fix(tls): remove the CRL host guard and document the remaining limits
cathleeny Nov 19, 2026
6bb5dc4
fix(tls): pin the kernel module while the CRL worker can run
cathleeny Nov 19, 2026
212dfe9
chore(deps): refresh napi, pyo3 and adbc lockfiles for the module pin
cathleeny Nov 19, 2026
46574b5
refactor(bindings): remove TLS revocation from pyo3 and napi
cathleeny Nov 20, 2026
115ac58
refactor(tls): check revocation with Windows CryptoAPI instead of a C…
cathleeny Nov 20, 2026
0ea26cc
docs(tls): document Windows-only revocation checking
cathleeny Nov 20, 2026
8f629a8
chore(deps): refresh napi, pyo3 and adbc lockfiles for the revocation…
cathleeny Nov 20, 2026
0940953
fix(config): show the revocation policy in TlsConfig's Debug output
cathleeny Nov 20, 2026
7495c7e
fix(tls): skip presented certificates CryptoAPI refuses
cathleeny Nov 20, 2026
45ce73a
build(tls): make rustls-native-certs a Windows-only dependency
cathleeny Nov 20, 2026
fc83cf5
ci(tls): run the Windows revocation module in PR checks
cathleeny Nov 20, 2026
976bcf1
ci(tls): run the Windows revocation job's cargo steps in pwsh
cathleeny Nov 20, 2026
65a87d8
refactor(tls): test the revocation support message on every platform
cathleeny Nov 20, 2026
6a98eec
docs(tls): document the synchronous revocation check and its bounds
cathleeny Nov 20, 2026
1fb2b46
test(tls): log CryptoAPI chain state and CRL requests on Windows
cathleeny Nov 20, 2026
20c261a
test(tls): rename the revocation live test to v0_ naming
cathleeny Nov 20, 2026
84edcd1
ci(tls): run the whole client suite on Windows
cathleeny Nov 20, 2026
ee783ea
fix(tls): retry an undetermined chain with a custom-root engine
cathleeny Nov 20, 2026
6efc95b
test(tls): cover a strict C ABI open against a revoked leaf on Windows
cathleeny Nov 20, 2026
04c85c4
fix(telemetry): key the client cache by revocation mode
cathleeny Nov 20, 2026
7e9b33e
ci(tls): quote the Windows test command so the workflow parses
cathleeny Nov 20, 2026
ae14d91
fix(tls): key the telemetry cache on the effective revocation mode
cathleeny Nov 20, 2026
d65949b
test(tls): compile the Windows C ABI revocation test on Windows
cathleeny Nov 20, 2026
6a9f2e6
fix(tls): share the revocation budget across a handshake's chain builds
cathleeny Nov 20, 2026
e9c4d28
fix(tls): treat a custom CA anchor as a root in the exclusive engine
cathleeny Nov 20, 2026
cd6573a
test(tls): cover a custom intermediate anchor and the multi-thread ru…
cathleeny Nov 20, 2026
8c42d30
docs(tls): state that trust anchors are not revocation-checked
cathleeny Nov 20, 2026
3f4ff95
ci(tls): run the C ABI revocation open test on Windows
cathleeny Nov 20, 2026
6b56287
test(tls): match the revoked error case-insensitively in the C ABI test
cathleeny Nov 20, 2026
8a40baa
fix(telemetry): report the revocation settings and key breakers by mode
cathleeny Nov 20, 2026
444125a
fix(tls): treat an invalid signature as undetermined and check staple…
cathleeny Nov 20, 2026
9a8086a
docs(tls): document stapled OCSP, the signature rule and the telemetr…
cathleeny Nov 20, 2026
2c5120e
fix(tls): stop the status at a custom CA anchor
cathleeny Nov 23, 2026
c8d6ecd
docs(tls): state that custom anchors and the certificates above them …
cathleeny Nov 23, 2026
95397f3
Merge main into feat/tls-certificate-revocation
cathleeny Nov 23, 2026
adb17d9
test(retry): pin revocation failures as permanent certificate errors
cathleeny Nov 23, 2026
c2b961d
fix(telemetry): log the plain host for the circuit breaker
cathleeny Nov 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,43 @@ jobs:

- name: Test client behavior (tls-rustls)
run: "cargo test -p databricks-sql-kernel --no-default-features --features tls-rustls --lib client::"

windows-revocation:
# The Windows-only revocation module (`client::tls_revocation`) and its tests compile
# only on Windows, so the Linux jobs above never build or run them. Same runner label
# and toolchain setup as the Windows job in `release-debuginfo.yml`.
name: Windows revocation (tls-rustls)
runs-on:
group: databricks-protected-runner-group
labels: [windows-server-latest]
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- uses: ./.github/actions/setup-jfrog

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

After main's #497, pr-checks.yml no longer grants id-token: write, and every job uses setup-public-package-proxies. This job still calls setup-jfrog, so it will fail the OIDC exchange once the branch is updated from main. Switch it to ./.github/actions/setup-public-package-proxies. Also, #499 already ignores RUSTSEC-2026-0543, so the CI note in the description can go.

with:
cargo: "true"

- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
toolchain: stable
components: clippy

- name: Set up MSVC environment
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1
with:
arch: x64

# pwsh, not the runner's default bash: Git Bash puts Git's coreutils `link` ahead of
# MSVC's `link.exe` on PATH, which breaks linking (as `release-debuginfo.yml` avoids).
- name: cargo clippy (tls-rustls, Windows)
shell: pwsh
run: cargo clippy -p databricks-sql-kernel --no-default-features --features tls-rustls --all-targets -- -D warnings

- name: Test client behavior (tls-rustls, Windows)
shell: pwsh
# Two runs: the client:: suite, then the C ABI revocation open test, which is not under client::.
run: |
cargo test -p databricks-sql-kernel --no-default-features --features tls-rustls --lib client::
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cargo test -p databricks-sql-kernel --no-default-features --features tls-rustls --lib c_abi::session::revocation_open_windows_tests
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ zeroize = "1.9"
jsonwebtoken = { version = "9", default-features = false, features = ["use_pem"] } # JWT signing (RS256/384/512, PS256/384/512, ES256/384); use_pem = PEM key loading (adds pem + simple_asn1, no TLS)
pkcs8 = { version = "0.10", features = ["encryption", "pem", "std"] } # PKCS#8 PEM parsing + PBES2 passphrase decryption

# Windows CryptoAPI for TLS certificate revocation (`src/client/tls_revocation.rs`).
# `windows-sys` is already in the lock file; no new packages.
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Security_Cryptography"] }
# `tls-rustls` on Windows only. Loads the OS trust store for the revocation verifier (see
# `src/client/tls_revocation.rs`), the same store reqwest's `rustls-tls-native-roots` loads.
rustls-native-certs = { version = "0.8", optional = true }

[dev-dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "io-util"] }
wiremock = "0.6"
Expand Down Expand Up @@ -212,6 +220,7 @@ tls-rustls = [
"dep:rustls",
"dep:rustls-webpki",
"dep:webpki-roots",
"dep:rustls-native-certs",
]

[lib]
Expand Down
13 changes: 13 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ changes go in their respective binding's NEXT_CHANGELOG.

### Added

- Opt-in TLS certificate revocation checking, off by default. It is supported
only on Windows with `tls-rustls`, where Windows CryptoAPI decides the status
after webpki has verified the chain. Requesting it anywhere else (including
`tls-native`) fails session open with `InvalidArgument`. Set it with
`TlsConfig::check_certificate_revocation` and
`TlsConfig::accept_undetermined_certificate_revocation`, or with
`kernel_session_config_set_tls_certificate_revocation`. CRL and OCSP fetches
use Windows' networking and proxy settings, and Windows caches their results.
The check is synchronous and runs inside the TLS handshake, so a connect or
operation timeout can be exceeded by up to the revocation budget (about 10 s
for CRL and OCSP retrieval in total). Session resumption is disabled while
revocation is on.

### Changed

### Updated
Expand Down
1 change: 1 addition & 0 deletions adbc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions docs/designs/tls-config-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,28 @@ E2E tests use mitmproxy as a TLS-intercepting proxy. The CI workflow (`.github/w
| Self-signed certs / skip cert validation | `databricks.http.tls.allow_self_signed` | `adbc.http_options.tls.allow_self_signed` + `adbc.http_options.tls.disable_server_certificate_validation` |
| Hostname mismatch | `databricks.http.tls.allow_hostname_mismatch` | `adbc.http_options.tls.allow_hostname_mismatch` |
| Custom CA cert | `databricks.http.tls.trusted_certificate_path` | `adbc.http_options.tls.trusted_certificate_path` |
| Cert revocation mode | Not supported | `adbc.http_options.tls.revocation_mode` |
| Cert revocation mode | Opt-in, Windows with tls-rustls only: `check_certificate_revocation`, `accept_undetermined_certificate_revocation` (default off; InvalidArgument elsewhere). Checked by Windows CryptoAPI. | `adbc.http_options.tls.revocation_mode` (ADBC mapping out of scope) |

### Naming Convention Difference

The Rust driver uses `databricks.http.tls.*` while the C# driver uses `adbc.http_options.tls.*`. This is consistent with the broader pattern: both drivers use different namespaces for driver-specific options (e.g., proxy is `databricks.http.proxy.*` in Rust vs `adbc.proxy_options.*` in C#). Neither namespace is part of the official ADBC specification — the `adbc.http_options.*` keys in C# are inherited from the HiveServer2 base class convention.

### Scope Exclusions

- **Certificate revocation mode**: reqwest does not expose CRL/OCSP configuration. The C# driver supports this via `adbc.http_options.tls.revocation_mode` because .NET's `HttpClientHandler` natively supports it. Can be revisited if reqwest adds support.
- **Certificate revocation is Windows-only**: the check exists only on Windows with `tls-rustls`, and is decided by Windows CryptoAPI (`CertGetCertificateChain`). On every other platform, and on `tls-native` (including Windows), requesting revocation fails session open with `InvalidArgument`, as an unsupported option does. The ODBC driver reads its CheckCertRevocation and AcceptUndeterminedRevocation keys only on Windows; elsewhere it warns and ignores them. The kernel does not port the check to Linux or macOS, and `tls-native` on Windows is not given a CryptoAPI path, because native-tls exposes no verifier hook and this keeps the surface smaller.
- **Trust stays with webpki**: the connection's webpki verifier, over the kernel's roots (webpki roots, the OS store, custom CAs), decides the chain, the name and the signatures, exactly as with revocation off. Only after that succeeds does CryptoAPI decide revocation. CryptoAPI builds its chain from the leaf, the presented intermediates and the custom CAs. It checks every certificate except the root. Only the chain-level revocation bits are read. The trust bits, including the root's, are ignored, so a custom CA that Windows does not trust is still checked, because the custom CAs are in CryptoAPI's additional store.
- **Telemetry cache limit**: the telemetry client cache key covers the host and the effective revocation mode only. Sessions to one host with different custom CA, self-signed, mTLS or proxy settings share a telemetry client, as before revocation was added. Per-session isolation is a follow-up.
- **Stapled OCSP**: a non-empty stapled OCSP response from the server is attached to the leaf certificate (`CERT_OCSP_RESPONSE_PROP_ID`, as SChannel does), so CryptoAPI can use it and skip a fetch for the leaf. rustls's client sends the `status_request` extension (OCSP) by default, so a server that staples gives the response to the check. An empty or refused response is ignored and CryptoAPI fetches as usual. There is no positive stapled-OCSP test yet: it needs an OCSP responder fixture, which is a follow-up.
- **Trust status**: a chain with an invalid signature on any element is undetermined, never good. Strict mode rejects it and accept-undetermined accepts it. A revoked status stays revoked.
- **Trust anchors**: a trust anchor is not revocation-checked, and neither are the certificates above it. A custom CA on the chain is an anchor, including a self-signed server certificate configured as a custom CA and a custom intermediate anchor, even when Windows can build past it to an installed root. This follows RFC 5280, the JDK PKIX path validator and CryptoAPI's exclude-root flag. The status is read from the leaf up to the first custom CA on the chain, using only the bits below it, so the chain-level bits (which include the anchor) are not used when the chain is cut. A chain without a custom CA is read as before. The rule is tested through a pure function on synthetic chains, because CI cannot install a root into the Windows store.
- **Chain choice**: CryptoAPI may build a different chain from the one webpki verified, for example through a cross-signed issuer. The status then comes from CryptoAPI's chain. The leaf is always checked. A server presenting more intermediates than it needs does not change the result. A presented certificate that CryptoAPI refuses to add is skipped, so it cannot hide the leaf's status; a chain that needs it comes out partial and is undetermined.
- **Strict and accept-undetermined**: a revoked status is rejected in both modes. An undetermined status (a fetch failure, an offline status, a missing revocation URL, or a partial chain) is rejected in strict mode and accepted under accept-undetermined. This matches Simba's semantics. A partial chain is a root that Windows cannot build to and that is not a custom CA, for example a public root that appears only in the webpki bundle. Under strict mode that connection fails.
- **CRL and OCSP fetching**: CryptoAPI retrieves CRLs and OCSP responses through Windows' networking stack (WinHTTP) and its proxy settings, not through the kernel's `ProxyConfig`. Windows caches the results, so a certificate revoked after a CRL was cached may be accepted until the cache refreshes. The kernel adds no CRL cache, worker thread, redirect policy or size limit of its own.
- **Timeout**: CryptoAPI applies one 10 s budget to the CRL and OCSP fetches of a chain (`CERT_CHAIN_REVOCATION_ACCUMULATIVE_TIMEOUT`). When the budget runs out, the status is undetermined. AIA and other chain-building fetches are bounded per URL (`dwUrlRetrievalTimeout`, also 10 s), not in total, so the 10 s total is not guaranteed for a chain that needs them. The kernel has no public knob for either bound.
- **Engine order and budget**: the default chain engine builds first, so a public chain that verifies costs one build. When custom CAs are configured and that build is undetermined, the chain is built again with an exclusive-root engine whose root store is the custom CAs. The second build gets only the time the first left (`dwUrlRetrievalTimeout` set to the remainder), and is skipped when none is left. One handshake therefore waits at most the 10 s budget for revocation fetches in total. The exclusive-root engine is used only for a second build, so public chains are not affected by its trust set.
- **Blocking**: the check is synchronous, because rustls' verifier is. It runs inside the handshake poll and blocks until CryptoAPI returns. On a multi-thread runtime, `block_in_place` moves the worker's other tasks to another thread, but the calling task cannot be cancelled until CryptoAPI returns. A caller's connect or operation timeout can be exceeded by up to the revocation budget, with revocation on only. On a `current_thread` runtime the whole runtime waits.
- **Session resumption**: resumption is disabled whenever revocation is on, because a resumed handshake skips the server certificate verifier, and a certificate revoked after the first handshake would stay accepted.
- **Documented limits**: the check covers the chain that CryptoAPI builds, not every path that webpki might accept. Windows caches revocation data. The check uses Windows' network stack, so proxy settings and firewall rules that the kernel does not control can make a fetch fail.
- **Client certificates (mTLS)**: Not needed per current requirements. Could be added later via `reqwest::ClientBuilder::identity()`.
- **TLS version pinning**: Not needed. reqwest/native-tls negotiate the highest supported version automatically.

Expand Down
26 changes: 26 additions & 0 deletions include/databricks_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,32 @@ KernelStatusCode kernel_session_config_set_tls_client_certificate(
KernelSessionConfig* config, const uint8_t* cert_pem, size_t cert_len,
const uint8_t* key_pem, size_t key_len);

/* Enable or disable TLS certificate-revocation checking (default: off).
*
* Supported only on Windows with the tls-rustls backend, where Windows CryptoAPI
* checks the revocation of the chain it builds for the server certificate, after
* webpki has verified the chain. A revoked certificate is always rejected.
* `accept_undetermined` governs a status that cannot be determined (a fetch
* failure or timeout, an offline status, a partial chain): false rejects it
* (strict), true accepts it. `check_revocation` false disables the check whatever
* `accept_undetermined` says. Revocation is also skipped when the self-signed
* setter is set.
*
* CRL and OCSP retrieval uses Windows networking and proxy settings, not the
* kernel's proxy configuration, and Windows caches the results. The check is
* synchronous: it blocks the calling thread's TLS handshake until CryptoAPI
* returns, so a connect or operation timeout can be exceeded by up to the
* revocation budget (about 10 s for CRL and OCSP retrieval in total, shared by a
* handshake's one or two chain builds; AIA and other chain-building fetches are
* bounded per URL, not in total). Session
* resumption is disabled while checking is on.
*
* Requesting it on any other platform, or on tls-native, makes opening a session
* fail with InvalidArgument, and the error names the unsupported platform or
* backend. */
KernelStatusCode kernel_session_config_set_tls_certificate_revocation(
KernelSessionConfig* config, bool check_revocation, bool accept_undetermined);

/* Configure the HTTP retry / backoff policy. `min_wait_ms` / `max_wait_ms`
* are the backoff-wait bounds between attempts (the wait is exponential
* with jitter, clamped to this range); `max_retries` is the number of
Expand Down
2 changes: 2 additions & 0 deletions napi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyo3/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading