Skip to content

Instantly share code, notes, and snippets.

@moxie0
Created November 28, 2011 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moxie0/1398985 to your computer and use it in GitHub Desktop.
Save moxie0/1398985 to your computer and use it in GitHub Desktop.
private InputStream makeRequest(Context context, URL url) {
AssetManager assetManager = context.getAssets();
InputStream keyStoreInputStream = assetManager.open("yourapp.store");
KeyStore trustStore = KeyStore.getInstance("BKS");
trustStore.load(keyStoreInputStream, "somepass".toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
tmf.init(trustStore);
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, tmf.getTrustManagers(), null);
HttpsURLConnection urlConnection = (HttpsURLConnection)url.openConnection();
urlConnection.setSSLSocketFactory(sslContext.getSocketFactory());
return urlConnection.getInputStream();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment