diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index a7e7242..a7176f0 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -43,9 +43,9 @@ env: CARGO_REGISTRY_VOLUME: onionwire-cargo-registry CARGO_TARGET_VOLUME: onionwire-target-ci BUILD_CONTAINER: onionwire-ci-${{ github.run_id }} - # The SDK job gets its own target volume: `crates/onionwire-sdk` is a - # separate cargo workspace with its own lockfile and its own crate set, so - # sharing a target dir with the root job would thrash both. + # The SDK job gets its own target volume: it resolves the root crate with + # `rustls` instead of `native-tls`, so sharing a target dir would thrash both + # jobs' feature-unified artifacts. SDK_CARGO_TARGET_VOLUME: onionwire-target-ci-sdk SDK_BUILD_CONTAINER: onionwire-ci-sdk-${{ github.run_id }} # The fuzz job builds on nightly with a release profile + debug=line-tables-only; @@ -83,6 +83,8 @@ jobs: -w /src \ "$RUST_IMAGE" \ 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 \ && cargo test --locked \ && cargo clippy --locked --all-targets -- -D warnings' @@ -91,19 +93,12 @@ jobs: docker rm -f "$BUILD_CONTAINER" > /dev/null # `crates/onionwire-sdk` is a SEPARATE cargo workspace: its own Cargo.lock and - # a path dependency on the root crate. The `test` job above therefore never - # compiles it, so a root-crate signature change (`Node::send` gaining the - # outbox result, the SQLCipher passphrase entry points) breaks the Android SDK - # — and the tagged release AAR, since android-release.yml only builds on - # `v*.*.*` — while both the root suites and local `cargo test` stay green. - # 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. + # a path dependency on the root crate, resolved with `rustls` instead of + # `native-tls`. The `test` job above therefore never compiles it, so a + # root-crate signature change (`Node::send` gaining the outbox result, the + # SQLCipher passphrase entry points) breaks the Android SDK — and the tagged + # release AAR, since android-release.yml only builds on `v*.*.*` — while both + # the root suites and local `cargo test` stay green. Build it here. sdk: runs-on: docker timeout-minutes: 120 diff --git a/Cargo.lock b/Cargo.lock index df3aebe..64a5690 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2645,7 +2645,6 @@ dependencies = [ "ratatui", "rpassword", "rusqlite", - "rustls", "safelog", "serde_json", "sha2", @@ -3501,7 +3500,6 @@ checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba" dependencies = [ "log", "once_cell", - "ring", "rustls-pki-types", "rustls-webpki", "subtle", diff --git a/Cargo.toml b/Cargo.toml index 7761aa5..e62e355 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,16 +8,16 @@ license = "MIT" publish = false repository = "https://github.com/sirius0xdev/onionwire" -# TLS backend: `rustls` by default, `native-tls` (OpenSSL) opt-in. +# The Linux TUI build is unchanged: `default` keeps Arti's native-tls +# (OpenSSL) backend exactly as before, and ratatui remains a normal +# dependency so `src/tui.rs` is untouched. # -# Arti marks these two backends non-additive, so exactly one may be selected per -# build graph — hence exposing them as crate features. rustls is the default -# because Android has no OpenSSL in the NDK and the Linux TUI/release build does -# 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.) +# Android has no OpenSSL in the NDK, so the SDK crate depends on this crate +# with `default-features = false, features = ["rustls"]`. Arti marks these two +# backends non-additive, so exactly one may be selected per build graph — hence +# exposing them as crate features. [features] -default = ["rustls"] +default = ["native-tls"] native-tls = ["arti-client/native-tls"] rustls = ["arti-client/rustls"] @@ -37,12 +37,6 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-util", "ti tor-cell = "0.46" tor-hsservice = "0.46" 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"] } x25519-dalek = { version = "2", features = ["static_secrets"] } snow = "0.10" diff --git a/README.md b/README.md index b173d67..2c6307a 100644 --- a/README.md +++ b/README.md @@ -88,10 +88,8 @@ cargo install --path . --locked --force # lands in ~/.cargo/bin/onionwire ``` -Build needs a C toolchain plus `perl` and `make`: SQLCipher is compiled from -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. +Build needs `pkg-config` and OpenSSL 3 headers (`libssl-dev` / `openssl-devel`) — +the released binaries link `libssl.so.3` dynamically. ### Two instances on one machine @@ -405,7 +403,7 @@ FORGEJO_TOKEN= scripts/build-release-local.sh v0.2.1 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, 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, `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/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/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). diff --git a/crates/onionwire-sdk/Cargo.lock b/crates/onionwire-sdk/Cargo.lock index d674106..926bffc 100644 --- a/crates/onionwire-sdk/Cargo.lock +++ b/crates/onionwire-sdk/Cargo.lock @@ -2776,7 +2776,6 @@ dependencies = [ "ratatui", "rpassword", "rusqlite", - "rustls", "safelog", "serde_json", "sha2", diff --git a/crates/onionwire-sdk/Cargo.toml b/crates/onionwire-sdk/Cargo.toml index a1a8227..7415714 100644 --- a/crates/onionwire-sdk/Cargo.toml +++ b/crates/onionwire-sdk/Cargo.toml @@ -7,8 +7,11 @@ description = "OnionWire Android/Kotlin SDK: in-process Arti onion transport, No license = "MIT" publish = false -# Standalone workspace on purpose: the SDK carries its own lockfile and its own -# crate set (Android: `static-sqlite`, rustls TLS), so it path-depends on the +# Standalone workspace on purpose. +# Arti's TLS backends (`native-tls` vs `rustls`) are non-additive: exactly one +# 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. [workspace] resolver = "2" diff --git a/crates/onionwire-sdk/README.md b/crates/onionwire-sdk/README.md index 1cd7124..9072542 100644 --- a/crates/onionwire-sdk/README.md +++ b/crates/onionwire-sdk/README.md @@ -126,7 +126,7 @@ output. ## Why this crate has its own Cargo workspace Arti's TLS backends are **non-additive**: exactly one of `native-tls` and -`rustls` may be enabled in a given feature resolution. The root crate defaults -to `rustls` (Linux TUI and releases), so this crate does not differ from the -root on TLS; it does add `static-sqlite`, because Android has no system -`libsqlite3`. Two separate workspaces keep the two resolutions from colliding. +`rustls` may be enabled in a given feature resolution. The Linux TUI keeps +`native-tls` (OpenSSL, as it always has). Android has no OpenSSL in the NDK, so +this crate selects `rustls` plus `static-sqlite` (no system `libsqlite3` on +Android). Two separate workspaces keep the two resolutions from colliding. diff --git a/docs/ARTI_UPGRADE.md b/docs/ARTI_UPGRADE.md index 1ca8b85..bb0ad7b 100644 --- a/docs/ARTI_UPGRADE.md +++ b/docs/ARTI_UPGRADE.md @@ -23,11 +23,9 @@ part of a Tor upgrade. Two crate features re-expose Arti's TLS backends, which Arti marks **non-additive** — exactly one may be selected per build graph: -* `rustls` (**default**) → every build: the Linux TUI, the released binaries and - the Android SDK. No system OpenSSL is needed for TLS; the root `Cargo.toml` - 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. +* `native-tls` (default) → Linux TUI build, via OpenSSL. +* `rustls` → the Android SDK crate (`crates/onionwire-sdk`), because the NDK has + no OpenSSL. 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 @@ -120,9 +118,8 @@ issue the watcher files. 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 send. There is no outbox in v1 — the message must not be silently queued. -8. Rebuild the Android target. The root crate defaults to `rustls` now, so this - is less about exercising a non-default feature than about proving the default - still cross-compiles where OpenSSL does not exist: +8. Rebuild the Android target — Arti's TLS backends are non-additive, and this + is the build that exercises the `rustls` feature: ``` scripts/build-android-local.sh ``` diff --git a/scripts/release-body.md b/scripts/release-body.md index c5804f8..5651385 100644 --- a/scripts/release-body.md +++ b/scripts/release-body.md @@ -18,8 +18,7 @@ chmod +x onionwire-x86_64-unknown-linux-gnu ./onionwire- --version ``` -Keep the asset filenames so `sha256sum -c` matches. The TLS stack is rustls and -OpenSSL (for SQLCipher) is compiled in from vendored sources, so the binaries -have no dynamic `libssl` dependency. +Keep the asset filenames so `sha256sum -c` matches. Both binaries link OpenSSL 3 +dynamically (`libssl.so.3`), which is standard on Debian 12+/Ubuntu 24.04+. Building from source is covered in the README install guide. diff --git a/tests/tls_backend.rs b/tests/tls_backend.rs deleted file mode 100644 index 20ab9ee..0000000 --- a/tests/tls_backend.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! 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" - ); -}