Skip to content

Debugging a Flutter App

Flutter’s HttpClient/dio/http packages don’t automatically trust a custom CA the way a browser does, and on iOS/Android the OS-level proxy setting isn’t always picked up by Dart’s networking layer either. Two things to get right.

1. Route traffic through the proxy

  • iOS Simulator / Android Emulator: usually inherit the host machine’s proxy automatically once TonyProxy is running — see Debugging an iOS App or Debugging an Android App for the underlying OS steps.
  • Physical device: set the device’s Wi-Fi proxy manually to your Mac’s LAN IP and port (9090 by default), same as any other app on that device.

2. Trust the CA in Dart’s networking layer

The OS trusting TonyProxy’s CA (via device Settings) is necessary but not always sufficient — some Dart HTTP clients bundle their own trust store instead of using the OS one. If requests still fail with a TLS/handshake error after the OS-level trust step:

  • For dio/http, configure the underlying HttpClient with a custom badCertificateCallback during development, or supply TonyProxy’s CA cert to SecurityContext explicitly.
  • Never ship a badCertificateCallback that accepts all certs to production — scope it to debug builds only.

Certificate pinning

If the app pins certificates (common in dio via certificate_pinning or similar packages), TonyProxy can’t decrypt that traffic no matter how well the CA is trusted — the app is explicitly rejecting anything but the real server’s exact cert. See HTTPS Decryption Issues.