tls: default to Arti's rustls backend (drop OpenSSL from TLS) #100

Merged
sirius merged 2 commits from wt/t_17e3d3cf-rustls-default into main 2026-09-18 01:20:36 +00:00
10 changed files with 91 additions and 38 deletions

View file

@ -43,9 +43,9 @@ env:
CARGO_REGISTRY_VOLUME: onionwire-cargo-registry CARGO_REGISTRY_VOLUME: onionwire-cargo-registry
CARGO_TARGET_VOLUME: onionwire-target-ci CARGO_TARGET_VOLUME: onionwire-target-ci
BUILD_CONTAINER: onionwire-ci-${{ github.run_id }} BUILD_CONTAINER: onionwire-ci-${{ github.run_id }}
# The SDK job gets its own target volume: it resolves the root crate with # The SDK job gets its own target volume: `crates/onionwire-sdk` is a
# `rustls` instead of `native-tls`, so sharing a target dir would thrash both # separate cargo workspace with its own lockfile and its own crate set, so
# jobs' feature-unified artifacts. # sharing a target dir with the root job would thrash both.
SDK_CARGO_TARGET_VOLUME: onionwire-target-ci-sdk SDK_CARGO_TARGET_VOLUME: onionwire-target-ci-sdk
SDK_BUILD_CONTAINER: onionwire-ci-sdk-${{ github.run_id }} SDK_BUILD_CONTAINER: onionwire-ci-sdk-${{ github.run_id }}
# The fuzz job builds on nightly with a release profile + debug=line-tables-only; # The fuzz job builds on nightly with a release profile + debug=line-tables-only;
@ -83,8 +83,6 @@ jobs:
-w /src \ -w /src \
"$RUST_IMAGE" \ "$RUST_IMAGE" \
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \ sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
&& apt-get update \
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
&& rustup component add clippy \ && rustup component add clippy \
&& cargo test --locked \ && cargo test --locked \
&& cargo clippy --locked --all-targets -- -D warnings' && cargo clippy --locked --all-targets -- -D warnings'
@ -93,12 +91,19 @@ jobs:
docker rm -f "$BUILD_CONTAINER" > /dev/null docker rm -f "$BUILD_CONTAINER" > /dev/null
# `crates/onionwire-sdk` is a SEPARATE cargo workspace: its own Cargo.lock and # `crates/onionwire-sdk` is a SEPARATE cargo workspace: its own Cargo.lock and
# a path dependency on the root crate, resolved with `rustls` instead of # a path dependency on the root crate. The `test` job above therefore never
# `native-tls`. The `test` job above therefore never compiles it, so a # compiles it, so a root-crate signature change (`Node::send` gaining the
# root-crate signature change (`Node::send` gaining the outbox result, the # outbox result, the SQLCipher passphrase entry points) breaks the Android SDK
# SQLCipher passphrase entry points) breaks the Android SDK — and the tagged # — and the tagged release AAR, since android-release.yml only builds on
# release AAR, since android-release.yml only builds on `v*.*.*` — while both # `v*.*.*` — while both the root suites and local `cargo test` stay green.
# the root suites and local `cargo test` stay green. Build it here. # Build it here.
#
# The root `test` job no longer installs `pkg-config`/`libssl-dev` — the root
# crate defaults to Arti's rustls backend, so TLS needs no system OpenSSL.
# The `rusqlite` `bundled-sqlcipher-vendored-openssl` feature that both jobs
# use compiles OpenSSL from source, which needs `perl` and `make` (present in
# the `rust:*-bookworm` image), not the `-dev` headers. This job keeps the
# install: the Android SDK build is unchanged by the root crate's TLS default.
sdk: sdk:
runs-on: docker runs-on: docker
timeout-minutes: 120 timeout-minutes: 120

2
Cargo.lock generated
View file

@ -2645,6 +2645,7 @@ dependencies = [
"ratatui", "ratatui",
"rpassword", "rpassword",
"rusqlite", "rusqlite",
"rustls",
"safelog", "safelog",
"serde_json", "serde_json",
"sha2", "sha2",
@ -3500,6 +3501,7 @@ checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba"
dependencies = [ dependencies = [
"log", "log",
"once_cell", "once_cell",
"ring",
"rustls-pki-types", "rustls-pki-types",
"rustls-webpki", "rustls-webpki",
"subtle", "subtle",

View file

@ -8,16 +8,16 @@ license = "MIT"
publish = false publish = false
repository = "https://github.com/sirius0xdev/onionwire" repository = "https://github.com/sirius0xdev/onionwire"
# The Linux TUI build is unchanged: `default` keeps Arti's native-tls # TLS backend: `rustls` by default, `native-tls` (OpenSSL) opt-in.
# (OpenSSL) backend exactly as before, and ratatui remains a normal
# dependency so `src/tui.rs` is untouched.
# #
# Android has no OpenSSL in the NDK, so the SDK crate depends on this crate # Arti marks these two backends non-additive, so exactly one may be selected per
# with `default-features = false, features = ["rustls"]`. Arti marks these two # build graph — hence exposing them as crate features. rustls is the default
# backends non-additive, so exactly one may be selected per build graph — hence # because Android has no OpenSSL in the NDK and the Linux TUI/release build does
# exposing them as crate features. # not need a system OpenSSL for TLS either. (OpenSSL is still *compiled* into
# every build by rusqlite's `bundled-sqlcipher-vendored-openssl`, vendored and
# static: that is the SQLCipher layer, not Arti's TLS.)
[features] [features]
default = ["native-tls"] default = ["rustls"]
native-tls = ["arti-client/native-tls"] native-tls = ["arti-client/native-tls"]
rustls = ["arti-client/rustls"] rustls = ["arti-client/rustls"]
@ -37,6 +37,12 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-util", "ti
tor-cell = "0.46" tor-cell = "0.46"
tor-hsservice = "0.46" tor-hsservice = "0.46"
tor-rtcompat = { version = "0.46", features = ["tokio"] } tor-rtcompat = { version = "0.46", features = ["tokio"] }
# Direct dependency only to select rustls's crypto provider: Arti pulls rustls in
# through `tor-rtcompat` with `default-features = false`, and rustls 0.23
# resolves its provider from its OWN `ring`/`aws-lc-rs` features, so without this
# line the rustls backend compiles with no provider at all and the first TLS
# config fails. Same reasoning (and pin) as `crates/onionwire-sdk/Cargo.toml`.
rustls = { version = "0.23", default-features = false, features = ["ring"] }
ratatui = { version = "0.30.2", default-features = false, features = ["crossterm"] } ratatui = { version = "0.30.2", default-features = false, features = ["crossterm"] }
x25519-dalek = { version = "2", features = ["static_secrets"] } x25519-dalek = { version = "2", features = ["static_secrets"] }
snow = "0.10" snow = "0.10"

View file

@ -88,8 +88,10 @@ cargo install --path . --locked --force
# lands in ~/.cargo/bin/onionwire # lands in ~/.cargo/bin/onionwire
``` ```
Build needs `pkg-config` and OpenSSL 3 headers (`libssl-dev` / `openssl-devel`) — Build needs a C toolchain plus `perl` and `make`: SQLCipher is compiled from
the released binaries link `libssl.so.3` dynamically. vendored OpenSSL sources (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`).
No system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is
`rustls`, and the binaries carry no dynamic `libssl` dependency.
### Two instances on one machine ### Two instances on one machine
@ -403,7 +405,7 @@ FORGEJO_TOKEN=<pat> scripts/build-release-local.sh v0.2.1
Workflows (Forgejo Actions, `.forgejo/workflows/`): Workflows (Forgejo Actions, `.forgejo/workflows/`):
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — two jobs on the Pi runner (`docker` label), serialized by `onionwire-ci-pi`. `test`: `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` at the repo root. `sdk`: the same for `crates/onionwire-sdk` (separate cargo workspace — own `Cargo.lock`, root crate by path, `rustls` instead of `native-tls` — so a root signature change cannot silently break the Android SDK). Both run on `main` and PRs when `src/`, `crates/`, `tests/`, `Cargo.toml`, `Cargo.lock`, or this workflow change (ignored Tor-live tests are not run). `workflow_dispatch` always runs the suite. - [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — two jobs on the Pi runner (`docker` label), serialized by `onionwire-ci-pi`. `test`: `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` at the repo root. `sdk`: the same for `crates/onionwire-sdk` (separate cargo workspace — own `Cargo.lock`, root crate by path, so a root signature change cannot silently break the Android SDK). Both run on `main` and PRs when `src/`, `crates/`, `tests/`, `Cargo.toml`, `Cargo.lock`, or this workflow change (ignored Tor-live tests are not run). `workflow_dispatch` always runs the suite.
- [`.forgejo/workflows/android-ci.yml`](.forgejo/workflows/android-ci.yml) — the android side of CI, on the `docker-amd64` runner: builds `:sdk:assembleRelease` + `:app:assembleRelease` with the same script the release uses (`scripts/build-android-local.sh`, Rust for `aarch64-linux-android` via cargo-ndk + UniFFI bindings) and verifies the packaged `libonionwire_sdk.so`, checksums and APK badging. Debug keystore, no publish, no tag. Runs on `main` and PRs when `android/`, `src/`, `crates/`, `Cargo.toml`, `Cargo.lock` or `scripts/build-android-local.sh` change. Same concurrency group **and** the same runner volumes as `android-release.yml`, so a PR build never fights a release build over the SDK/NDK, cargo and Gradle caches. - [`.forgejo/workflows/android-ci.yml`](.forgejo/workflows/android-ci.yml) — the android side of CI, on the `docker-amd64` runner: builds `:sdk:assembleRelease` + `:app:assembleRelease` with the same script the release uses (`scripts/build-android-local.sh`, Rust for `aarch64-linux-android` via cargo-ndk + UniFFI bindings) and verifies the packaged `libonionwire_sdk.so`, checksums and APK badging. Debug keystore, no publish, no tag. Runs on `main` and PRs when `android/`, `src/`, `crates/`, `Cargo.toml`, `Cargo.lock` or `scripts/build-android-local.sh` change. Same concurrency group **and** the same runner volumes as `android-release.yml`, so a PR build never fights a release build over the SDK/NDK, cargo and Gradle caches.
- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — manual, batched release (`workflow_dispatch` only: `dry_run`, `bump`, `version`, `tag`): next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release, fail-closed tag delete on failure. Dispatch [`android-release.yml`](.forgejo/workflows/android-release.yml) with that tag to add the APK + AAR (no automatic trigger fires on this Forgejo; it is `workflow_dispatch` only). Concurrency group `onionwire-ci-pi` (same as `ci.yml`, `cancel-in-progress: false`) so cargo jobs do not overlap on the Pi. Amd64 dind is serialized by runner `capacity=1`. - [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — manual, batched release (`workflow_dispatch` only: `dry_run`, `bump`, `version`, `tag`): next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release, fail-closed tag delete on failure. Dispatch [`android-release.yml`](.forgejo/workflows/android-release.yml) with that tag to add the APK + AAR (no automatic trigger fires on this Forgejo; it is `workflow_dispatch` only). Concurrency group `onionwire-ci-pi` (same as `ci.yml`, `cancel-in-progress: false`) so cargo jobs do not overlap on the Pi. Amd64 dind is serialized by runner `capacity=1`.
- [`.forgejo/workflows/android-release.yml`](.forgejo/workflows/android-release.yml) — amd64-only Android build (dispatch-only on this Forgejo; wakes from an explicit `tag=` input, not a tag push). - [`.forgejo/workflows/android-release.yml`](.forgejo/workflows/android-release.yml) — amd64-only Android build (dispatch-only on this Forgejo; wakes from an explicit `tag=` input, not a tag push).

View file

@ -2776,6 +2776,7 @@ dependencies = [
"ratatui", "ratatui",
"rpassword", "rpassword",
"rusqlite", "rusqlite",
"rustls",
"safelog", "safelog",
"serde_json", "serde_json",
"sha2", "sha2",

View file

@ -7,11 +7,8 @@ description = "OnionWire Android/Kotlin SDK: in-process Arti onion transport, No
license = "MIT" license = "MIT"
publish = false publish = false
# Standalone workspace on purpose. # Standalone workspace on purpose: the SDK carries its own lockfile and its own
# Arti's TLS backends (`native-tls` vs `rustls`) are non-additive: exactly one # crate set (Android: `static-sqlite`, rustls TLS), so it path-depends on the
# may be enabled per feature resolution. The Linux TUI crate keeps native-tls,
# Android has no OpenSSL in the NDK and needs rustls. Two separate workspaces
# keep the two resolutions from colliding — this crate path-depends on the
# root package without joining its feature graph. # root package without joining its feature graph.
[workspace] [workspace]
resolver = "2" resolver = "2"

View file

@ -126,7 +126,7 @@ output.
## Why this crate has its own Cargo workspace ## Why this crate has its own Cargo workspace
Arti's TLS backends are **non-additive**: exactly one of `native-tls` and Arti's TLS backends are **non-additive**: exactly one of `native-tls` and
`rustls` may be enabled in a given feature resolution. The Linux TUI keeps `rustls` may be enabled in a given feature resolution. The root crate defaults
`native-tls` (OpenSSL, as it always has). Android has no OpenSSL in the NDK, so to `rustls` (Linux TUI and releases), so this crate does not differ from the
this crate selects `rustls` plus `static-sqlite` (no system `libsqlite3` on root on TLS; it does add `static-sqlite`, because Android has no system
Android). Two separate workspaces keep the two resolutions from colliding. `libsqlite3`. Two separate workspaces keep the two resolutions from colliding.

View file

@ -23,9 +23,11 @@ part of a Tor upgrade.
Two crate features re-expose Arti's TLS backends, which Arti marks Two crate features re-expose Arti's TLS backends, which Arti marks
**non-additive** — exactly one may be selected per build graph: **non-additive** — exactly one may be selected per build graph:
* `native-tls` (default) → Linux TUI build, via OpenSSL. * `rustls` (**default**) → every build: the Linux TUI, the released binaries and
* `rustls` → the Android SDK crate (`crates/onionwire-sdk`), because the NDK has the Android SDK. No system OpenSSL is needed for TLS; the root `Cargo.toml`
no OpenSSL. pins rustls's `ring` feature so the crypto provider resolves from crate
features (without it the rustls backend compiles with no provider).
* `native-tls` → opt-in only, via OpenSSL.
Published Arti releases move all four crates together in lockstep. Bump them as Published Arti releases move all four crates together in lockstep. Bump them as
**one set**. A mixed set (e.g. `arti-client` 0.47 with `tor-hsservice` 0.46) is **one set**. A mixed set (e.g. `arti-client` 0.47 with `tor-hsservice` 0.46) is
@ -118,8 +120,9 @@ issue the watcher files.
7. Confirm the fail-closed path by hand if the publish wait changed at all: 7. Confirm the fail-closed path by hand if the publish wait changed at all:
with the write timeout still 360s, a peer whose onion is down must fail the with the write timeout still 360s, a peer whose onion is down must fail the
send. There is no outbox in v1 — the message must not be silently queued. send. There is no outbox in v1 — the message must not be silently queued.
8. Rebuild the Android target — Arti's TLS backends are non-additive, and this 8. Rebuild the Android target. The root crate defaults to `rustls` now, so this
is the build that exercises the `rustls` feature: is less about exercising a non-default feature than about proving the default
still cross-compiles where OpenSSL does not exist:
``` ```
scripts/build-android-local.sh scripts/build-android-local.sh
``` ```

View file

@ -18,7 +18,8 @@ chmod +x onionwire-x86_64-unknown-linux-gnu
./onionwire-<target> --version ./onionwire-<target> --version
``` ```
Keep the asset filenames so `sha256sum -c` matches. Both binaries link OpenSSL 3 Keep the asset filenames so `sha256sum -c` matches. The TLS stack is rustls and
dynamically (`libssl.so.3`), which is standard on Debian 12+/Ubuntu 24.04+. OpenSSL (for SQLCipher) is compiled in from vendored sources, so the binaries
have no dynamic `libssl` dependency.
Building from source is covered in the README install guide. Building from source is covered in the README install guide.

36
tests/tls_backend.rs Normal file
View file

@ -0,0 +1,36 @@
//! 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"
);
}