Intercepting iOS simulator network traffic through a debugging proxy
iOS simulator network traffic and Android emulator traffic through mitmproxy: the right proxy setting, CA trust on Android 7+, and debug builds that skip pinning.
- Written by
- Yuvan Sundrani
- Read time
- 10 min read
- Published
.png)
Key Takeaways
- The Android Emulator Proxy tunnels HTTPS without decrypting it; Google's docs say to use the Android System Proxy (Wi-Fi settings) for inspecting app traffic.
- Apps targeting API 24 and later trust only system CAs, so a proxy CA installed as a user certificate is ignored unless the app opts in.
- A CA listed under <debug-overrides> is trusted only in debuggable builds, and network security config skips pinning for chains signed by it.
- OkHttp's CertificatePinner runs in code, after the TLS handshake, and network security config doesn't switch it off.
- Apps that pin their certificate reject interception, and that applies to our iOS network capture too: capture runs against a debug build without pins.
A request reaches a debugging proxy readable only after it clears three gates: the device routes it to the proxy, the app trusts the proxy's CA, and no pin rejects the proxy's certificate.
Android emulator proxy setup for HTTPS inspection
mitmproxy listens on http://localhost:8080 by default, per its getting-started guide. Each device needs a different route to that port.
iOS Simulator. mitmproxy's instructions for the Simulator begin by configuring the Mac running it to use the proxy in its network settings; the Simulator's traffic then follows the Mac's.
Android Emulator. Google's emulator proxy guide separates two mechanisms:
| Android System Proxy | Emulator Proxy | |
|---|---|---|
| Where it's set | Settings > Network & Internet > Wi-Fi, on the device | -http-proxy, or Extended controls > Settings > Proxy |
| Layer | Device HTTP proxy setting | TCP tunnel at the network layer |
| HTTPS inspection | Yes, once the proxy's certificate is installed | No; traffic is forwarded without decryption |
| Caveat | Some apps ignore the system proxy | Needs an emulator restart; no host bypass list |
The guide also says the two are mutually exclusive. An emulator started with -http-proxy sends traffic through the proxy but never shows decrypted requests, which looks like a CA problem and isn't one.
Set the Wi-Fi proxy to host 10.0.2.2, port 8080. The emulator maps that address to the host loopback, so the proxy only needs to listen on 127.0.0.1. The full address map is in Android emulator localhost on cloud devices. For a phone on Wi-Fi, the proxy has to listen on the LAN interface.
In an Autosana sandbox on the iOS Simulator, this gate doesn't exist: autosana sandbox network --failed --since 3 lists failed requests from step 3 onward with no proxy configured.

Proxy CA certificate install by platform
On first run, mitmproxy writes a CA to ~/.mitmproxy; mitmproxy-ca-cert.pem is the copy for most platforms. Browsing to mitm.it on the device serves an installer.
iOS Simulator. Per mitmproxy's steps: download the certificate from mitm.it in Safari, install it under Settings > General > VPN & Device Management, then enable full trust under Settings > General > About > Certificate Trust Settings.
Skipping the last step leaves the profile installed and the root untrusted. xcrun simctl also lists a keychain <device> add-root-cert subcommand in its built-in help, which scripts the same result.
Android, own app. Android's network security config guide states the default: all apps trust the preinstalled system CAs, and only apps targeting API 23 or lower also trust user-added CAs. A user-installed proxy CA is invisible to anything built against a current SDK. The documented opt-in is <debug-overrides>, which applies only when android:debuggable is true:
res/xml/network_security_config.xml:
<network-security-config>
<debug-overrides>
<trust-anchors>
<certificates src="@raw/mitmproxy_ca" />
</trust-anchors>
</debug-overrides>
</network-security-config>
Put the PEM at res/raw/mitmproxy_ca.pem. Because the guide states that debug-overrides is ignored when the app isn't debuggable, this block can live in the main config. A config that already allows cleartext or pins domains takes the block alongside its other elements.
Android, third-party or release builds. No app change is possible, so the CA has to go into the system store. mitmproxy's guide for that targets /system/etc/security/cacerts/ on a rooted emulator and was tested on API 26 to 30.
On Android 14, AOSP moved root trust into the updatable Conscrypt module APEX, so expect that method to need rework on current images.

SSL pinning testing in debug builds
A trusted proxy CA still fails if the app pins. Each platform has a declarative pin and a code-level pin, and they're switched off differently.
Pin
Platform
Debug build without it
<pin-set> in network security config
Android
Nothing to do: the guide says pinning is skipped for chains signed by a debug-overrides anchor
OkHttp CertificatePinner
Android
Install the pinner only when !BuildConfig.DEBUG
NSPinnedDomains in Info.plist (iOS 14+)
iOS
Leave the key out of the Debug configuration's plist
Custom URLSessionDelegate trust evaluation
iOS
Compile the check under #if !DEBUG
OkHttp's failure is easy to spot in Logcat:
javax.net.ssl.SSLPeerUnverifiedException: Certificate pinning failure!
Peer certificate chain:
sha256/...: CN=mitmproxy, O=mitmproxy
Pinned certificates for api.example.com:
sha256/...
OkHttp's own documentation says the pinner runs after a successful TLS handshake and before the connection is used. So the proxy shows a completed handshake, then nothing; the evidence is in the app log.
val builder = OkHttpClient.Builder()
if (!BuildConfig.DEBUG) {
builder.certificatePinner(
CertificatePinner.Builder()
.add("api.example.com", "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
.build()
)
}
Testing that pinning works is the release build's job: point it at the proxy and confirm every pinned host fails. The mobile app security testing post covers where that check sits in a security pass.
Our iOS capture follows the same rule. Our network docs state that apps pinning their TLS certificate reject interception and don't appear in the list, so the Debug configuration above is also what makes our Network section populate.
Failed request analysis: 4xx, timeouts, retry storms
Three patterns explain most blank screens.
4xx and 5xx. A 401 behind a blank screen is usually an expired or missing token, one of the failures API testing for mobile shows passing API suites miss.
Test credentials for AI agents covers keeping those valid across runs. A 5xx points at the backend; check whether the app renders an error state for it at all.
Timeouts. A request with no response before the client's deadline. Compare its duration against the client's configured timeout, then against the same endpoint in a healthy run.
Retry storms. The same method and URL repeated within seconds. OkHttp's retryOnConnectionFailure silently recovers from unreachable IPs, stale pooled connections and unreachable proxies, so some repeats are the client working as designed. A dozen identical POSTs is an app-level retry loop.
We write each run's requests as JSONL (network_log_url in the Runs API) with method, url, status (0 for a failed request), duration_ms and error. Both checks are one line:
# failed requests
jq -c 'select(.status == 0 or .status >= 400) | {method, url, status, error}' network.jsonl
# repeated requests, most frequent first
jq -r '"\(.method) \(.url)"' network.jsonl | sort | uniq -c | sort -rn | head
Our tests can assert on the same data mid-run. Our network traffic docs give the form: read the network logs and verify the POST to /api/login returned 200. That turns "the screen was blank" into a failed assertion naming the endpoint. Captured iOS traffic is metadata only (method, URL, status, timing, size), so bodies still need the proxy.
Autosana for app network traffic debugging
Autosana is an AI end-to-end testing agent for iOS, Android and web apps. When a screen comes up blank, we record what the app requested during the run, so the failing call is visible without a proxy for the common cases.
Autosana key features for network debugging
- Failed requests listed per step. On the iOS Simulator, autosana sandbox network --failed --since 3 lists the requests that failed from step 3 onward. There's no proxy to route and no certificate to install, which removes the first two gates for this check.
- A request list on every run. Each finished iOS or web run shows its requests with method, URL, status, timing and size, and failed ones carry status 0 with an error. The same list comes back as JSONL from the Runs API for the checks shown above.
- Network checks inside the test. A test written as an instruction can include one, for example "Sign in with the test account, then read the network logs and check that the login request returned 200." A blank screen then fails with the endpoint named.

A run's detail page: status, the instructions it ran, the agent's summary, and device logs to download when a screen comes up blank. Source: Autosana Suites docs video.
Autosana customer results
- Ziina (UAE financial platform) automated 69% of its E2E suite and cut active manual regression from about 12 hours across two days to about 1 hour. Their mobile platform engineer: "It's not a deterministic tool, which is very good because then it gives you flexibility." See the Ziina case study.
Where Autosana fits less well
- Our iOS capture records metadata only (method, URL, status, timing, size); request and response bodies still need the proxy.
- Apps that pin their certificate don't appear in our iOS capture, so run a debug build without pins.
- network --failed in sandboxes covers the iOS Simulator only.
- Web runs cover Chrome, Firefox, Edge and Chromium, with no Safari.
Why use Autosana for app network traffic debugging?
- Blank screens get a cause. The failing request appears next to the step that showed the blank screen.
- No proxy for the first look. The request list exists on every iOS and web run without setup.
- Assertions name the endpoint. A test can fail on "login returned 500" before anyone opens a capture.
- Retry storms are countable. The JSONL export makes repeats per endpoint a one-line query.
- Free tier to try it. Pay as you go starts with up to 1,000 free AI actions a month.
Conclusion
The three gates fail silently and look alike: no traffic, a handshake that dies, a handshake that succeeds before the app refuses it. Check the proxy setting (Wi-Fi proxy, never -http-proxy), then the trust anchors, then the app log for a pinning exception.
Two numbers per run are worth tracking once traffic is visible: failed requests per step and repeats per endpoint. Both come from a proxy capture or from our JSONL export without extra tooling, and a rise in either shows up before users report the blank screen.
FAQs
1. Why can't the proxy decrypt Android Emulator traffic?
The Emulator Proxy tunnels TCP without decryption. Use the Wi-Fi system proxy instead.
2. Why does Android ignore my installed proxy certificate?
Apps targeting API 24 and later trust only system CAs unless their network security config opts in.
3. Does debug-overrides disable certificate pinning?
For network security config pins, yes. OkHttp's CertificatePinner still runs and needs its own debug check.
4. How do I trust a proxy CA on the iOS Simulator?
Install it from mitm.it, then enable full trust in Certificate Trust Settings.
5. What does an OkHttp pinning failure look like?
SSLPeerUnverifiedException: Certificate pinning failure!, followed by the peer chain and pinned hashes.
6. Does Autosana capture traffic from apps that pin certificates?
No. Its iOS capture skips pinned apps, so run a debug build without pins.
Sources


