- 19 Oct 2024
- 1 Minute à lire
- SombreLumière
Integrate SSL pinning
- Mis à jour le 19 Oct 2024
- 1 Minute à lire
- SombreLumière
The SSL pinning feature verifies the public keys of servers before allowing communication. A list of accepted public key of certificates is embedded inside the application, and any HTTPS request to a host that is not pinned will be refused.
To enable SSL pinning, you need to embed either the SSL certificate or the public key of your server in your mobile application. Upon connection, the client compares the server's certificate or public key against the embedded one. If they match, the connection is established, if they do not match, the connection is terminated.
You can export a PEM-encoded certificate from a keystore using the keytool with this command:
keytool -export -alias MyCertificateAlias -keystore MyKeyStore.keystore -rfc -file MyPEMCertificate.pem
You can export a PEM-encoded certificate using OpenSSL with this command:
openssl x509 -pubkey -noout -in MyPEMCertificate.pem