Repository navigation
fix(android): restore Core HTTPS and wss:// TLS after the reqwest 0.13 upgrade - #1253
Open
DepengWang wants to merge 1 commit into
Open
DepengWang wants to merge 1 commit into
DepengWang wants to merge 1 commit into
Conversation
reqwest 0.13 in openless-core verifies certificates through rustls-platform-verifier, which panics on Android until it is given the JVM and application Context, so every LLM request and provider validation died inside its task. Initialize it when OpenLessApplication registers its Context, and wire the org.rustls:rustls-platform-verifier AAR into the generated Gradle project (version read from Cargo.lock, the AAR's app-wide networkSecurityConfig removed so the app keeps its own cleartext policy, classes kept for R8) on every Android build path. The same registration also installs the process-default CryptoProvider (tls_crypto, Open-Less#1250) that tokio-tungstenite's wss:// ASR clients need, since it runs before any Activity enters run(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DepengWang
force-pushed
the
fix/android-tls-crypto-provider
branch
from
October 22, 2026 10:30
838d7d1 to
2bc7c4e
Compare
Contributor
Author
|
提醒一下:main 刚同步到 beta( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Since #1117 moved openless-core to reqwest 0.13, an Android build from
betacannot reach any cloud provider. Every LLM request, every provider "Verify", and WebSocket cloud ASR (e.g. Volcengine) fail. Local ASR still works, and desktop is fine. No published release is affected yet: the last release (v2.0.2-Beta.1, 10-17) and the last Android CI APK (10-19) both predate #1117. The next release would ship it.There are two independent causes, both rustls panics inside a spawned task. Nothing reaches the log: Rust panics don't go to logcat, and the UI only sees the failure. #1250 has since fixed the second cause in
run(); this PR fixes the first one and closes the remaining Android gap in the second.1. rustls-platform-verifier is never initialized on Android (HTTPS)
reqwest 0.13's
rustlsfeature verifies certificates throughrustls-platform-verifier. On Android, that crate calls the platform TrustManager through JNI. It panics on the first HTTPS request (Expect rustls-platform-verifier to be initialized) unless:Context(init_with_env), andorg.rustls:rustls-platform-verifierAAR, is in the APK.Neither was done.
src/android/tls_verifier.rsinitializes the verifier fromnativeRegisterActivityContext, whichOpenLessApplication.onCreatecalls before Core sends anything. The crate is built on jni-rs 0.22 while this crate uses 0.21, so 0.22 is added asjni022and the rawJNIEnv/Contextpointers are passed across. Initialization is idempotent. An error is logged ([android-tls]) instead of unwinding across JNI.scripts/patch-android-rustls-verifier.mjs, in the same style aspatch-android-shizuku-deps.mjs. It patches the generated project:src-tauri/Cargo.lock(rustls-platform-verifier-android), so the Kotlin and Rust halves cannot drift. It resolves from the project's official Maven archive on GitHub. A local Maven copy (OPENLESS_RUSTLS_MAVEN, or<OPENLESS_CACHE_ROOT>/rustls-maven) is preferred when present, for offline or proxied builds.android:networkSecurityConfig. It forbids cleartext everywhere except a list of CA CRL hosts. That would silently override ourusesCleartextTrafficplaceholder, for example the cleartext the debug build allows for local providers. It is removed withtools:remove.org.rustls.platformverifier.**, since Rust looks those classes up by name.2. No process-default rustls CryptoProvider (wss:// ASR)
tokio-tungstenite's
rustls-tls-webpki-rootsconnector builds itsClientConfigfrom the process-defaultCryptoProvider. The graph now enables both rustls providers:ringthrough this crate,aws-lc-rsthrough reqwest 0.13. So rustls cannot choose one and panics on the firstwss://connect ("Could not automatically determine the process-level CryptoProvider"). In the log, the ASR session goes toerror~130 ms after[asr] Volcengine connect, with no message.tls_crypto::install_tls_crypto_provider()installsringfirst thing inrun().tls_verifier::initcalls the same function. On Android,OpenLessApplication.onCreateregisters the Context before any Activity entersrun(), so a process that only hosts the keyboard has a provider before its first dictation. The call is idempotent.Build paths
The patch step is added next to
patch-android-shizuku-deps.mjseverywhere the Gradle project is prepared:.github/workflows/android-apk.ymlandci.ymlscripts/build-android-local.shandscripts/run-android-tauri-dev.mjsandroid/README.mdCompatibility
cfg(target_os = "android").Test plan
Before the fix: Android arm64 build of
beta(df73ad07), plus my own non-network patches, on a OnePlus CPH2573 and a Xiaomi M2011K2C. LLM verify, ASR verify (Volcengine) and cloud dictation all failed. Windows on the same commit was fine.Fix 1 only: LLM verify and polish worked, ASR verify still failed.
Fix 1 + 2: on the OnePlus, ASR verify, LLM verify and Volcengine cloud dictation all pass on a debug build and on a release build (Rust LTO + R8).
CertificateVerifieris present in the release dex after R8, and the merged manifest has nonetworkSecurityConfig.Provider installed from both
run()and the Context registration: rebuilt as a debug build on the OnePlus, with ASR verify, LLM verify and cloud dictation all passing. This was tested before rebasing onto fix(desktop): Fix and organize the new version, and refine the version. #1250, with an equivalent function of my own inlib.rs. After the rebase, the sameringinstall comes from fix(desktop): Fix and organize the new version, and refine the version. #1250'stls_crypto. The rebased commit itself was not re-tested on a device.node scripts/patch-android-rustls-verifier.test.mjs(contract checks):It also runs under
npm test.cargo check --lib --lockedforx86_64-pc-windows-msvcandaarch64-linux-androidon the rebased commit.🤖 Generated with Claude Code