Mobile security · senior
Network security and SSL pinning
SSL pinning makes the app trust only your server's known public keys, which blocks man-in-the-middle attacks that use a malicious or user-installed root certificate, but it needs backup pins and a rotation plan, or one certificate change can break every installed app.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Normal TLS trusts any certificate authority in the device store. Pinning adds a rule: the server's key must also match a hash shipped inside the app.
- Pin the public key (SPKI hash) of an intermediate or your own key, and always ship at least one backup pin (TrustKit on iOS requires at least two pins).
- Options: react-native-ssl-public-key-pinning (TrustKit on iOS, OkHttp CertificatePinner on Android; covers fetch, XHR and axios), Android network_security_config with <pin-set> and an expiration date, or native OkHttp/URLSession setup.
- Certificates expire every 1–2 years. Ship the new pin as a backup long before rotation. Pins in native config cannot be fixed by an OTA JS update.
- Pinning can be bypassed on rooted phones with Frida; add attestation (Play Integrity, App Attest) for high-risk actions.
- Also: HTTPS only (App Transport Security on iOS, cleartext traffic off on Android), and no secrets in URLs.
- Disable the expo-dev-client network inspector when you test pinning in development builds.
The red pen
Common traps: mistake → fix
Mistake: "Pin only the leaf certificate with no backup"
Fix: the next rotation bricks the app.
Mistake: "Pinning makes the API secure"
Fix: it protects the channel; the server must still authorise every call.
Mistake: "We can change pins over the air"
Fix: not if they live in native config.
Easy to hard
Questions interviewers ask, easy to hard
- Implement SSL pinning for your payments API.
- Pin the leaf, the intermediate or the public key? Why?
- The certificate rotates next month. What is your plan?
- Can an attacker bypass pinning? What do you add?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.