Certificate pinning
The SDK provides functionality to pin your servers certificate. Please note, if you pin the servers certificate itself you will need to deploy a new version of the application when you change the servers certificate. The best alternative is to use the intermediate certificate of the Certificate Authority used to get your SSL servers certificate (the second level in the certificate chain). This gives you the option to renew the server certificate without having to deploy a new version of the application.
Manual Certificate Pinning
Export the certificate
You can use Firefox to export the certificate. Click on the lock of the SSL website. Choose: more information. In the security tab press View certificate. Then go to the details tab. And there you can choose which certificate in the chain you wish to export.
Certificate tampering protection
To prevent tampering or at least detect if a certificates are replaced by a different ones, the certificates are provided to the client in base64 format. To obtain base64 encoded certificate the DER encoded certificate must be converted to PEM format with the following command:
The content of the<filename>.pem file is an armored base64 representation of the certificate. The content of the file stripped from its armour:
---Begin---
...
---End---
rows must be provided to the client before a service request is made. Best practice is to add the base64 encoded certificate to the client
during initialization using ClientBuilder
.
Automated Certificate Pinning
Certificate Pinning can be done automatically as a part of the process done by SDK Configurator. In this case calling setX509PEMCertificates:
method is not required. ClientBuilder
automatically finds ConfigModel
in order to configure certificates correctly.