Skip to content

fix(http): read the OS trust store on the tls-rustls backend (odbc#323) - #316

Merged
vikrantpuppala merged 1 commit into
mainfrom
fix/odbc-323-rustls-native-roots
Sep 6, 2026
Merged

vikrantpuppala merged 1 commit into
mainfrom
fix/odbc-323-rustls-native-roots

Conversation

@vikrantpuppala

Copy link
Copy Markdown
Collaborator

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 surfaced 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 — the whole reason tls-rustls was selected there.

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; the napi binding builds with the changed feature.

Downstream

Once merged, databricks-odbc bumps KERNEL_REPO_TAG to this commit to give its aarch64 package system-CA parity with x86_64/i686 — no ODBC packaging change needed.

@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.

Verdict: 1 Low

Looks good — a clean, well-justified additive TLS change. The tls-rustls feature correctly gains rustls-tls-native-roots, the updated debug comment is accurate, and the new hermetic test's API usage matches the public surface; all new transitive crates are under already-allow-listed licenses so no deny.toml change is needed. One low-severity nit: pyo3/Cargo.lock wasn't regenerated even though pyo3 also builds on tls-rustls.

Comment thread Cargo.toml
# fallback lost). This gives the aarch64 cross-build — the only Linux arch on
# `tls-rustls` — system-CA parity with the x86_64/i686 OpenSSL builds. See
# odbc#323.
tls-rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — The tls-rustls feature now pulls in rustls-native-certs (and openssl-probe, schannel, security-framework, core-foundation). The root Cargo.lock and napi/Cargo.lock were regenerated to include these, but pyo3/Cargo.lock — which also resolves the kernel with features = ["tls-rustls"] (pyo3/Cargo.toml:75) — was not: it still has no rustls-native-certs entry. This isn't a CI failure (pyo3-checks runs cargo test without --locked, so cargo silently regenerates the lockfile at build time), but it leaves the committed pyo3 lockfile drifted from the feature change and inconsistent with the other two lockfiles the PR did update. Regenerate it (cd pyo3 && cargo update -p reqwest --precise <same> or a plain cargo build then commit the lockfile) so the pinned dependency graph reflects the new trust-store crates.

## 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>

@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.

@vikrantpuppala
vikrantpuppala added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit 9ecd357 Sep 6, 2026
26 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — a4ed9d7e Deployed Sep 5, 2026 by vikrantpuppala via review #536
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.

2 participants