Update check panics on Android: rustls-platform-verifier is never initialized
On Android (Termux), Fresh's update check panics in rustls-platform-verifier, because nothing initializes it: fresh --cmd update --check exits with code 101, and in the editor the daily background check prints the backtrace over the screen.
Steps to reproduce
On Termux, with Fresh 0.5.2 from the Termux package (pkg install fresh-editor):
fresh --cmd update --checkOutput, with exit code 101:
Installed via: unknown (confidence: Unknown)
thread 'main' (16702) panicked at /home/builder/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustls-platform-verifier-0.6.2/src/android.rs:94:10:
Expect rustls-platform-verifier to be initialized
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::option::expect_failed
3: rustls_platform_verifier::android::global
4: <rustls_platform_verifier::verification::android::Verifier as rustls::verify::ServerCertVerifier>::verify_server_cert
5: <rustls::client::tls13::ExpectCertificateVerify as rustls::common_state::State<rustls::client::client_conn::ClientConnectionData>>::handle
6: rustls::conn::ConnectionCommon<Data>::complete_io
7: rustls::stream::Stream<C,T>::complete_prior_io
8: <ureq::unversioned::transport::chain::Either<A,B> as ureq::unversioned::transport::Transport>::transmit_output
9: ureq::run::run
10: ureq::request::do_call
11: ureq::request::RequestBuilder<ureq::request::WithoutBody>::call
12: fresh_update::fetch::latest
13: fresh_update::engine::run
14: fresh::run_if_subcommand
15: fresh::real_main
16: fresh::mainStarting the editor with check_for_updates on gives the same trace from fresh_update::fetch::latest, drawn over the editor view. The editor keeps running. "check_for_updates": false avoids it.
Environment: Android 16, aarch64, Termux 0.118.0, Fresh 0.5.2 (Termux package, built with default features).
Cause
fresh-update enables ureq's platform-verifier feature (crates/fresh-update/Cargo.toml). On Android, rustls-platform-verifier reads the system trust store through the JVM, and its docs require one of android::init_with_env, init_with_runtime or init_with_refs before the first verification. Nothing in the Fresh source calls any of them. Termux programs are plain native processes with no JVM to hand over, so Fresh cannot call them there either.
Possible fixes
On Android builds, pick root certificates that need no JVM. Two options, and I have not checked which fits ureq 3's TlsConfig better:
- ureq's bundled WebPKI roots.
- The CA bundle Termux ships at
$PREFIX/etc/tls/cert.pem.
What I did not check
- Whether 0.5.1 behaves the same. It uses the same dependency, but I did not test it before upgrading.
- Other HTTPS paths, such as plugin package installs. I expect the same panic, since the verifier is the same, but I only ran the update check.
Separately, Installed via: unknown shows the updater does not recognize the Termux package as package-managed. Even with TLS working, it would offer a self-update over an install that pkg owns.
Source: sinelaw/fresh