Skip to content

Instantly share code, notes, and snippets.

@develodroid
Last active July 5, 2016 18:40
Show Gist options
  • Save develodroid/7beee0a6aba18e3f2c96c1ce73af9ade to your computer and use it in GitHub Desktop.
Save develodroid/7beee0a6aba18e3f2c96c1ce73af9ade to your computer and use it in GitHub Desktop.
//In order to extract a peer certificate:
File certificate = new File(certificateUri);
String peerCertificate = PeerCertificateExtractor.extract(certificate);
//Retrieved peer certificates format:
sha256/u4QJrwx7aSejc080BBQKGyTaoJovFBg4SbQ9nhoohb8=
//Enabling okhttp certificate pinning is now made the following way:
client = new OkHttpClient.Builder()
.certificatePinner(new CertificatePinner.Builder()
.add("publicobject.com", peerCertificate)
.build())
.build();
https://github.com/fabiomsr/okhttp-peer-certificate-extractor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment