Skip to content

Commit ca170ff

Browse files
vikrantpuppalaIsaac
andcommitted
fix(http): read the OS trust store on the tls-rustls backend (odbc#323)
## Summary The `tls-rustls` kernel backend validated server certificates against Mozilla's bundled `webpki-roots` **only**, ignoring the OS system trust store that the default `tls-native` (OpenSSL) backend reads. A server whose chain terminates in a **private/internal CA installed only in the system store** (`/etc/ssl/...`) therefore failed the TLS handshake under `tls-rustls` while succeeding under `tls-native`. This surfaces as a Linux **aarch64**-specific support case for the ODBC driver: aarch64 is the only Linux arch cross-built onto `tls-rustls` (to avoid a cross OpenSSL), so its packages diverged from the x86_64 / i686 OpenSSL builds behind a corporate MITM proxy or an internal PKI. See databricks/databricks-odbc#323. ## What changed `tls-rustls` now enables `reqwest/rustls-tls-native-roots` alongside `reqwest/rustls-tls`. reqwest defaults both `tls_built_in_certs_webpki` and `tls_built_in_certs_native` to `true` when their features are on, so it loads the OS trust store (via `rustls-native-certs`) **and** the Mozilla bundled roots into one `RootCertStore`. The change is strictly additive — the webpki fallback is retained — and applies equally to the napi / pyo3 bindings, which also build on `tls-rustls`. `rustls-native-certs` is pure Rust (it reads `/etc/ssl/...` / honours `SSL_CERT_FILE`), so the aarch64 cross-build needs no cross C OpenSSL. ## Test plan - New hermetic integration test `tests/tls_rustls_native_roots.rs` (gated on `tls-rustls`): generates a private CA + server cert at runtime, serves HTTPS from it, exposes the CA as the OS trust store via `SSL_CERT_FILE`, and drives the kernel's default HTTP client (no custom CA, no `allow_self_signed`). Fails with the old webpki-roots-only wiring (unknown issuer), passes with the fix. - `cargo test --no-default-features --features tls-rustls`: 916 pass; the sole failure (`mtls_identity_is_forwarded_when_session_opens`) is pre-existing on `origin/main` under `tls-rustls` and unrelated to this change (mTLS identity-parse error ordering, not trust store). - `cargo clippy` + `cargo fmt --check` clean on both backends; napi binding builds with the changed feature. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
1 parent 1c6cdda commit ca170ff

5 files changed

Lines changed: 321 additions & 4 deletions

File tree

‎Cargo.lock‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,17 @@ tokio-rustls = { version = "0.26.4", default-features = false, features = ["ring
192192
[features]
193193
default = ["tls-native"]
194194
tls-native = ["reqwest/native-tls"]
195-
tls-rustls = ["reqwest/rustls-tls"]
195+
# `rustls-tls` alone is `reqwest/rustls-tls-webpki-roots` — the bundled Mozilla
196+
# root set only, which does NOT read the OS system trust store. `tls-native`
197+
# (native-tls → OpenSSL) DOES read `/etc/ssl/...`, so a `tls-rustls` build behind
198+
# a private/internal CA installed only in the OS store fails a handshake that the
199+
# `tls-native` build completes. Enabling `rustls-tls-native-roots` alongside makes
200+
# reqwest load the OS trust store AND the Mozilla bundled roots into one
201+
# `RootCertStore` (both `tls_built_in_certs_*` default true → additive, no
202+
# fallback lost). This gives the aarch64 cross-build — the only Linux arch on
203+
# `tls-rustls` — system-CA parity with the x86_64/i686 OpenSSL builds. See
204+
# odbc#323.
205+
tls-rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"]
196206

197207
[lib]
198208
name = "databricks_sql_kernel"

‎napi/Cargo.lock‎

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/client/http.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,11 @@ impl DatabricksHttpClient {
479479

480480
// Surface which TLS backend was compiled in so oncall debugging
481481
// a handshake / unknown-CA report can tell at a glance whether
482-
// this binary is on native-tls (system CA store) or rustls
483-
// (Mozilla webpki-roots). The two stacks differ on cert
484-
// validation behavior, OCSP, and TLS 1.3 quirks.
482+
// this binary is on native-tls or rustls. Both read the OS system
483+
// CA store (rustls via `rustls-tls-native-roots`, which also keeps
484+
// the Mozilla webpki-roots as a fallback — see odbc#323), but the
485+
// two stacks still differ on cert validation behavior, OCSP, and
486+
// TLS 1.3 quirks.
485487
debug!(
486488
tls_backend = if cfg!(feature = "tls-rustls") {
487489
"rustls"

0 commit comments

Comments
 (0)