Repository navigation
fix(ffi): verify default clients with the OS platform verifier - #511
Merged
Merged
Conversation
Quest-Claim: dbf414231c90fba2
Python, Kotlin and Swift clients without certificate hashes or disabled verification now verify with rustls-platform-verifier on the crate's provider instead of rustls-native-certs, which finds no roots on iOS or Android. On Android, JNI_OnLoad initializes the verifier from ActivityThread.currentApplication(), and each new client retries until it succeeds, trusting bundled webpki-roots meanwhile. The AAR loads the library through System.loadLibrary from a startup ContentProvider (JNA skips JNI_OnLoad), bundles the verifier's Kotlin component, and ships its keep rule. Closes #506 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 11, 2026 08:51
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 44 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Collaborator
Author
|
Merge summary:
(Written by Claude Opus 5.5) |
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.
Python, Kotlin and Swift clients using default verification (no
server_certificate_hashes, nono_cert_verification) now verify servers with rustls-platform-verifier on the crate's existing provider (rind), so the OS trust store decides on every platform, including iOS and Android.rustls-native-certsis dropped fromweb-transport-ffi. Follows moq-dev/moq#1968.Closes #506
Changes
rs/web-transport-ffi: the default branch ofClient::newinstallsrustls_platform_verifier::Verifier::new(provider).src/android.rs): exportsJNI_OnLoad, which registers theJavaVMand initializes the verifier fromActivityThread.currentApplication(). If the Application is null or a JNI call throws, the error is logged withtracing, the exception is cleared by jni 0.22'sattach_current_thread, and the library load still succeeds. Each new default-verification client retries initialization throughJavaVM::singleton(). Until initialization succeeds, Android clients trust bundledwebpki-roots, and a client built during that fallback keeps them. The fallback is Android-only.ContentProvider(internal, not exported) callsSystem.loadLibrary("web_transport_ffi")at startup, after the Application exists. JNA alone never runsJNI_OnLoad. AnUnsatisfiedLinkErrorthere is logged rather than crashing startup; JNA still reports it on first use.org.rustls:rustls-platform-verifier:0.2.0) is bundled into the AAR (libs/classes.jar). Gradle downloads it from upstream's GitHub Maven repo (anexclusiveContentrepository limited toorg.rustls) and checks a pinned SHA-256.consumer-rules.proships the upstream keep rule.rustls-platform-verifier-android = "=0.2.0"inweb-transport-ffi(ignored by cargo-shear) pins the crate to the Kotlin component version inkt/gradle.properties. If an upgrade needs a different component version, Cargo resolution fails instead of shipping a mismatch.quest/a1/ffi-platform-verifier.mdand updates the siblingquest/a1/platform-verifier.md, which pointed to it.Compatibility
ClientConfig, the generated bindings, and the Python/Kotlin/Swift wrappers are identical; the only new Kotlin class isinternal. No version bump.Client()now fails at construction withInvalidArgument("platform verifier: No CA certificates were loaded from the system")when no system CA certificate can be loaded. Before, construction succeeded and every connection failed. On macOS/Windows/iOS the OS verifier also applies OS policy (enterprise roots, distrust, revocation where supported). Android apps now loadlibweb_transport_ffi.soat app startup instead of on first use.Choices made without asking
org.rustls:rustls-platform-verifierfrom another Rust library will hit duplicate classes.android:networkSecurityConfigon<application>, which would conflict with apps that set their own, and setscleartextTrafficPermitted="false"app-wide. It exists only so best-effort CRL fetches can use HTTP. The Kotlin verifier usesPKIXRevocationChecker.Option.SOFT_FAIL, so the cost is weaker best-effort revocation, not failed verification.System.loadLibrary. It runs beforeApplication.onCreateand aftercurrentApplication()is set, soJNI_OnLoadsucceeds on its first try in normal apps. Apps can remove it withtools:node="remove"; the per-client retry then still covers clients built after the first explicitSystem.loadLibrary.Verification
Ran locally:
just checkandjust test: pass. That includes newdefault_verification_rejects_untrusted_server, which asserts that a default client rejects a self-signed loopback server withUnknownIssuer.cargo clippy -p web-transport-ffi --lib -- -D warningsforaarch64-linux-android,armv7-linux-androideabiandaarch64-apple-ios, using a rustup toolchain isolated under.tmp/(the Nix shell has no Android/iOS std): clean.libweb_transport_ffi.soforaarch64-linux-androidwith NDK 30 (from nixpkgsandroidenv):JNI_OnLoadis exported.gradlew -Pandroid.enabled=true :web-transport:assembleRelease :web-transport:lintReleasewith that SDK: the AAR contains the provider in its manifest,proguard.txtwith the keep rule, theorg.rustls.platformverifierclasses inlibs/classes.jar, and the.so. Lint reports only the pre-existing AGP/JNA version warnings.just test-kotlin(packaged JVM JAR smoke): passes.wheelfailure).Not exercised at runtime: nothing ran on an Android device/emulator or on iOS/macOS. In particular, these are untested:
JNI_OnLoadinitialization throughcurrentApplication(), the ContentProvider ordering, the per-client retry and webpki fallback, verification through Android's TrustManager using the bundled Kotlin classes, R8 with the keep rule, and Apple SecTrust verification. CI here has no emulator or simulator. TheSwift runtimemacOS job will exercise the host macOS build, but not default verification.Suggested follow-ups
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)