SSL pinning and a debugging proxy
An app with pinning rejects the proxy's certificate even when it is installed and trusted. How to recognise pinning, what the proxy still shows, and how to turn pinning off in a debug build of your own app.
What pinning is
An app normally trusts any certificate chained to a trusted CA; you made the proxy's root trusted, so the proxy decrypts. Pinning adds a check against a list of certificates or public keys built into the app. The proxy's certificate is not on it, so the connection fails. No proxy setting gets around it.
How to recognise pinning
- Errors on some hosts only, usually the app's own API; analytics or image hosts decrypt.
- A browser on the same device opens sites without warnings.
- The proxy reports a client handshake failure: a
certificate_unknownalert or a drop with no alert. OkHttp'sCertificatePinnerchecks after the handshake, so the handshake completes and the client closes without sending a request. See SSL handshake failed through a proxy. - The app reports no connection while the network is fine.
What the proxy shows without decryption
Add the host to the proxy's exclusions: it is tunnelled undecrypted and the app works. The recording keeps the host and port, the time and number of connections and, in most proxies, bytes each way. It loses paths, headers, bodies, status codes and response replacement.
Your own app: turn pinning off in the debug build
Android, network_security_config. Pins in a <pin-set>: let user
certificates override them in debug builds only:
<network-security-config>
<domain-config>
<domain includeSubdomains="true">api.example.com</domain>
<pin-set expiration="2027-06-01">
<pin digest="SHA-256">7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y=</pin>
</pin-set>
</domain-config>
<debug-overrides>
<trust-anchors>
<certificates src="user" overridePins="true" />
</trust-anchors>
</debug-overrides>
</network-security-config>
debug-overrides applies only with android:debuggable="true"; release
builds ignore it.
Android, OkHttp. Add the CertificatePinner in release only:
val builder = OkHttpClient.Builder()
if (!BuildConfig.DEBUG) {
builder.certificatePinner(
CertificatePinner.Builder()
.add("api.example.com", "sha256/7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y=")
.build()
)
}
iOS, NSPinnedDomains. Pins in Info.plist cannot be disabled in code.
Point the Debug configuration's INFOPLIST_FILE at a separate Info.plist
without NSPinnedDomains.
iOS, pinning in code. A URLSession delegate check or Alamofire's
ServerTrustManager: wrap it in #if !DEBUG and leave the system's default
evaluation in Debug.
Looks like pinning, but is not
- The app bypasses the proxy. Flutter, for example, ignores the system proxy. The recording is empty, not full of errors.
- An Android app ignores user certificates. Errors on all the app's hosts. Fix: Android does not trust the proxy certificate.
- QUIC. UDP traffic goes past the proxy.
All six causes: why a proxy does not see an app's traffic.
See it on your own traffic
In Solpuga, add a pinned host in Settings → SSL Proxying → Bypass list, or with Add Host to Bypass List in a request's context menu. The bypass list wins over the selected list: the host is tunnelled, the app works, and its requests are recorded without content. Details: Certificate Installation.
Related
- Why an HTTPS proxy does not see an app's trafficThe proxy is set up and the certificate is installed, yet the app's requests are missing or die in the TLS handshake. Six scenarios, with a network-level diagram of each and what it looks like in the proxy.
- SSL handshake failed through a proxy — client side or server sideAn intercepting proxy runs two TLS handshakes: with the app and with the server. How to tell which one failed, and what to fix in each case.
- Android does not trust the proxy certificateApps built for Android 7+ ignore user-installed CAs. How to allow them in a debug build with network_security_config, and what it will not fix.