onionwire/tests/tls_backend.rs
Hermes rust-dev 69672809ab
All checks were successful
ci / test (pull_request) Successful in 6m47s
android-ci / android (pull_request) Successful in 8m21s
ci / sdk (pull_request) Successful in 1m25s
tls: default to Arti's rustls backend (drop OpenSSL from TLS)
Arti's TLS backends are non-additive; the root crate defaulted to
`native-tls` (OpenSSL). Switch `default = ["rustls"]` and pin the `rustls`
crate with its `ring` feature — `tor-rtcompat` pulls rustls in with
`default-features = false`, so without that pin the backend compiles with no
`CryptoProvider` and the first TLS config fails (same reason already recorded
in crates/onionwire-sdk/Cargo.toml).

`native-tls` stays as an opt-in feature. SQLCipher still builds vendored
OpenSSL (`bundled-sqlcipher-vendored-openssl`); that is unrelated to TLS.

- tests/tls_backend.rs: compile-time pin that the default features select
  rustls, plus a runtime check that rustls resolves a provider with no manual
  install.
- ci.yml: the root `test` job no longer installs pkg-config/libssl-dev (the
  SDK job keeps it).
- docs: README build deps, ARTI_UPGRADE backend table, release-body and the
  SDK README now describe the rustls default; the false "binaries link
  libssl.so.3 dynamically" claim is corrected.
- crates/onionwire-sdk/Cargo.lock: regenerated for the root crate's new
  dependency (separate workspace, --locked would otherwise fail).
2026-09-17 20:48:05 -04:00

36 lines
1.6 KiB
Rust

//! Pin the crate's default TLS backend to Arti's `rustls` feature.
//!
//! The TUI/release build and the Android SDK are the same crate compiled with
//! different feature sets, and Arti's two TLS backends are non-additive. The
//! default must be `rustls` so no build pulls OpenSSL in for TLS (Android has
//! no OpenSSL in the NDK, and the released binaries should not need a system
//! OpenSSL).
// The default feature set must select `rustls`, not `native-tls`.
//
// Pinned at compile time: this test target is built with the crate's default
// features, so it stops compiling if `default` ever moves back off Arti's
// rustls backend.
const _: () = assert!(cfg!(feature = "rustls"));
const _: () = assert!(!cfg!(feature = "native-tls"));
/// Building a `rustls` config the way Arti does works with no manual provider
/// install, straight from the process default.
///
/// This is the load-bearing half: `tor-rtcompat` depends on rustls with
/// `default-features = false`, so unless *this* crate turns on rustls's `ring`
/// feature the TLS backend compiles with no `CryptoProvider` and Arti dies the
/// first time it builds a TLS config.
#[test]
fn rustls_resolves_a_crypto_provider_from_crate_features() {
assert!(
rustls::crypto::CryptoProvider::get_default().is_none(),
"another test in this binary installed a CryptoProvider first"
);
let _ = rustls::ClientConfig::builder();
assert!(
rustls::crypto::CryptoProvider::get_default().is_some(),
"rustls resolved no CryptoProvider — the crate feature that selects one \
(`ring`) is missing from the dependency graph"
);
}