A while back I wrote about “Using SSL right on Android“. If you are using OkHttp and/or Retrofit, this should be quite simple to implement. You can use the CertificatePinner class when building your OkHttpClient instance.
Example:
- CertificatePinner certificatePinner = new CertificatePinner.Builder()
- .add("example.com", "your_pin")
- .build();
- new OkHttpClient.Builder()
- .certificatePinner(certificatePinner)
- .build();
More details about HTTPS and certificate pinning with OkHttp can be found on their Wiki, as well as a full example.