Created
November 28, 2011 03:35
-
-
Save moxie0/1398985 to your computer and use it in GitHub Desktop.
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
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