Skip to content

rust: default to rustls TLS backend, add native-tls opt-in#1806

Open
colbylwilliams wants to merge 1 commit into
github:mainfrom
colbylwilliams:colby-rust-rustls-tls-backend
Open

rust: default to rustls TLS backend, add native-tls opt-in#1806
colbylwilliams wants to merge 1 commit into
github:mainfrom
colbylwilliams:colby-rust-rustls-tls-backend

Conversation

@colbylwilliams

Copy link
Copy Markdown
Member

Summary

Fixes #1805.

The Rust crate hard-coded the OpenSSL-backed native-tls stack for its request-handler HTTP and WebSocket clients, with no way to opt into rustls:

reqwest = { version = "0.12", default-features = false, features = ["stream", "http2", "default-tls"] }
tokio-tungstenite = { version = "0.24", default-features = false, features = ["connect", "native-tls"] }

default-tls (reqwest) and native-tls (tokio-tungstenite) both pull in openssl-sys, which links the system OpenSSL on Linux. This breaks *-unknown-linux-musl / fully-static builds (no OpenSSL sysroot) and adds a dynamic libssl.so.3 runtime dependency on glibc.

Change

This implements both shapes the issue proposed: default to rustls and expose a native-tls cargo feature so consumers keep the choice.

  • rustls-tls (new, default): reqwest rustls-tls-native-roots + tokio-tungstenite rustls-tls-native-roots — rustls with the ring provider and the OS trust store. OpenSSL-free, so musl/static targets cross-compile without a system OpenSSL sysroot.
  • native-tls (new, opt-in): keeps the platform-native stack (OpenSSL on Linux, Secure Transport on macOS, SChannel on Windows) for consumers who want it.
  • Base reqwest/tokio-tungstenite deps drop their hard-coded TLS features; TLS is now selected via the cargo features above.

The transport code (copilot_request_handler.rs) is TLS-backend-agnostic (reqwest::Client::builder() + connect_async), so no source changes were required. For wss://, tokio-tungstenite resolves the rustls crypto provider via Cargo feature unification on the shared rustls crate (reqwest pins ring).

Note: default-features = false now drops the default rustls-tls backend along with bundled-cli; re-add rustls-tls or native-tls. This is documented in the README.

Validation

  • cargo build (default) is OpenSSL-free: openssl-sys no longer appears in the normal dependency graph; ring is the sole rustls crypto provider.
  • cargo check --no-default-features --features rustls-tls and --features native-tls both compile.
  • Verified at runtime that the default rustls wss:// path resolves the ring crypto provider (reaches the TLS handshake instead of panicking with "no process-level CryptoProvider available").
  • cargo +nightly fmt --check, cargo clippy --all-features --all-targets -- -D warnings: clean.
  • cargo test --all-features: green (177 lib + 365 e2e + integration + 23 doctests).
  • Request-handler e2e tests pass under the default rustls-only build (--features test-support).

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

The Rust crate hard-coded the OpenSSL-backed native-tls stack for its
request-handler HTTP (reqwest `default-tls`) and WebSocket
(tokio-tungstenite `native-tls`) clients, pulling in `openssl-sys`. That
breaks `*-unknown-linux-musl` / fully-static builds (no OpenSSL sysroot)
and adds a dynamic `libssl` runtime dependency on glibc.

Make TLS feature-gated and default to rustls:

- `rustls-tls` (default): reqwest `rustls-tls-native-roots` +
  tokio-tungstenite `rustls-tls-native-roots`, using rustls with the
  `ring` provider and the OS trust store. OpenSSL-free, so musl/static
  targets cross-compile with no system OpenSSL.
- `native-tls` (opt-in): keeps the platform-native stack for consumers
  who want it.

The transport code is TLS-backend-agnostic (`reqwest::Client::builder()`
+ `connect_async`), so no source changes were needed. For `wss://`,
tokio-tungstenite resolves the rustls crypto provider via feature
unification on the shared `rustls` crate (reqwest pins `ring`).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@colbylwilliams colbylwilliams requested a review from a team as a code owner June 26, 2026 11:46
Copilot AI review requested due to automatic review settings June 26, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Rust SDK crate’s dependency feature wiring so the request-handler transport (reqwest + tokio-tungstenite) defaults to a rustls-based TLS stack (to avoid OpenSSL on Linux/musl/static builds) while still providing an opt-in native-tls feature for consumers who want the platform TLS backend.

Changes:

  • Make rustls-tls a new default crate feature and add an opt-in native-tls feature to select the TLS backend.
  • Remove hard-coded TLS feature selection from the base reqwest and tokio-tungstenite dependency declarations.
  • Document the new feature behavior and default-features = false implications in the Rust README.
Show a summary per file
File Description
rust/README.md Documents new rustls-tls (default) and native-tls (opt-in) features and shows updated dependency examples.
rust/Cargo.toml Adds TLS-selection crate features and removes hard-coded TLS features from transport dependencies.
rust/Cargo.lock Lockfile updates reflecting the new (feature-gated) dependency graph.

Review details

  • Files reviewed: 2/3 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread rust/Cargo.toml
Comment on lines +34 to +38
# TLS backend for the request-handler HTTP/WebSocket transport. Exactly one
# should be enabled; `rustls-tls` is the default. `rustls-tls` uses rustls with
# the `ring` provider and the OS trust store, keeping the SDK OpenSSL-free so
# musl/static targets build without an OpenSSL sysroot. `native-tls` links the
# platform stack (OpenSSL on Linux, Secure Transport on macOS, SChannel on
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.

Rust SDK hard-codes native-tls (OpenSSL); offer a rustls TLS backend so musl/static builds work

2 participants