Last active
December 13, 2016 12:11
-
-
Save beetsolutions/c539b0a64ef064930bd3bcaf8187760c to your computer and use it in GitHub Desktop.
Get Certificate pinning sha with Square OKHTTP 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make sure this does not run on the main thread. | |
String hostname = "yourdomain.com"; | |
CertificatePinner certificatePinner = new CertificatePinner.Builder() | |
.add(hostname, "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=") | |
.build(); | |
OkHttpClient client = new OkHttpClient.Builder() | |
.certificatePinner(certificatePinner) | |
.build(); | |
Request request = new Request.Builder() | |
.url("https://" + hostname) | |
.build(); | |
try { | |
client.newCall(request).execute(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
// Inspect the error details for the correct sha | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment