Repository navigation
fix(mobile): connect to pinned gateways on ios - #268
Merged
Merged
Conversation
With ATS on, URLSession evaluates server trust again after the delegate accepts the pinned certificate, against the system roots and host name. The computer's self-signed certificate fails it (NSURLErrorDomain -1200, -9802), so every RPC failed after a successful TLS probe. IP hosts can't get a per-domain exception, so ATS is relaxed and the pin stays the only trust decision. NSAllowsLocalNetworking is dropped: it makes iOS ignore NSAllowsArbitraryLoads. Native error domains and codes now end the transport messages on iOS and Android, including probe failures and the stream reconnect banner. Related: #61
This was referenced Nov 13, 2026
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.
Root cause
The first production iOS build (TestFlight) failed to pair at once with
[unknown] Connection interrupted. Try again., while Android works against the same gateway.I reproduced it on an iOS 26.3 simulator with a Release build (same ATS settings as
production), pairing over HTTPS with pinning against a throwaway gateway with network access on (self-signed P-256 listener certificate, reached over Tailscale from the Mac).The CFNetwork log of the failing request:
SecPolicyCreateBasicX509plus the pinned certificate as the only anchor on the trust object first. It made no difference: the ATS evaluation still failed onAnchorTrustedandSSLHostname.probeuses Network.framework, which ATS doesn't cover. So the route check passed and the first RPC failed.h2and TLS 1.3 / ECDHE, which ATS accepts.Fix
app.config.ts:NSAppTransportSecurity: { NSAllowsArbitraryLoads: true }.NSExceptionDomainscan't take IP addresses, and gateway host names are set by the user, so a per-domain exception isn't possible.NSAllowsLocalNetworkingis removed: when it is present, iOS ignoresNSAllowsArbitraryLoads.NSAllowsArbitraryLoadsneeds a justification. Ours: the app connects to a user-hosted server (an IP address or a custom name) with a self-signed certificate, verified by a SHA-256 fingerprint pinned during pairing. This is noted indocs/mobile.md.Native error codes in the UI
A failure can now be diagnosed from a screenshot. The code goes in parentheses; it never includes an address.
onErrorcarriesNSURLErrorDomain -1200 / -9802(the domain, the code and the TLS stream error). Probe failures carryPOSIX 61,TLS -9808,DNS …ortimeout.SSLHandshakeException / CertPathValidatorException.pinned.tsadds the code to the message.routes.tsadds probe codes to "Cannot reach this computer securely…". Stream reconnects show it in the "Connection lost" banner.Verified (iOS 26.3 simulator, Release build, HTTPS + pin, gateway reached over Tailscale)
[unknown] Connection interrupted. Try again.(same as TestFlight).[unknown] Could not connect to this computer. Check the network, then try again. (NSURLErrorDomain -1200 / -9802).SecTrustSet*anchor lines, which I removed afterwards.stream.tsbanner change, which is JS only.bun install,gen:check,typecheck,lint,format:checkandexpo lintare clean.check:tmp: 1454 pass. Three Git-origin tests inadd-project/linked-projectsfailed only because I had set TMPDIR inside the git worktree; they pass with the default TMPDIR. No mobile tests are involved.Not verified:
codefield (class names), and Android typecheck andexpo lintpass.Copy audit (docs/copy.md §8)
Connection interrupted. Try again.(any non-pin failure)Could not connect to this computer. Check the network, then try again. (code)Connection interrupted. Try again.Connection interrupted. Try again. (code)Cannot reach this computer securely. …(code, …)Connection lost. Reconnecting automatically…(code)when the transport gave oneShow details. That goes against §4.4 on purpose: the mobile pair screen and the banner have no details disclosure, and the task needs the code to be visible in a screenshot. The codes are short and in parentheses at the end.Related: #61