Mobile app Legitimate server MITM attacker

Certificate Pinning & MITM Defense (2D)

This simulator plays out the exact decision a mobile app makes on every HTTPS connection, using real cryptography end to end: a real ECDSA P-256 key pair per node (app-trusted server, and β€” when active β€” a MITM attacker), a real SPKI export of whichever public key is presented, and a real SubtleCrypto SHA-256 hash compared byte-for-byte against a pinned hash constant. A normal CA-chain check alone (step 1) accepts any certificate the simulated CA is shown, which is exactly how a compromised CA or an installed MITM proxy root defeats plain TLS. Certificate pinning adds a second, independent real check: the freshly computed hash of the presented key must equal a hash hardcoded ahead of time. Toggle pinning and the MITM attacker to see interception succeed or genuinely fail on the real hash comparison, and use the certificate-rotation control to see pinning's own failure mode β€” locking out a legitimate key rotation β€” unless a backup pin was staged in advance.