Skip to content

Instantly share code, notes, and snippets.

@moxie0
Created November 28, 2011 03:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save moxie0/1398995 to your computer and use it in GitHub Desktop.
Save moxie0/1398995 to your computer and use it in GitHub Desktop.
TrustManager[] trustManagers = new TrustManager[1];
trustManagers[0] = new PinningTrustManager(new String[] {"f30012bbc18c231ac1a44b788e410ce754182513"});
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, trustManagers, null);
HttpsURLConnection urlConnection = (HttpsURLConnection)new URL("https://encrypted.google.com/").openConnection();
urlConnection.setSSLSocketFactory(sslContext.getSocketFactory());
InputStream in = urlConnection.getInputStream();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment