Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private Socket constructSSLSocket(Context context, String host, int port) {
AssetManager assetManager = context.getAssets();
InputStream keyStoreInputStream = assetManager.open("yourapp.store");
KeyStore trustStore = KeyStore.getInstance("BKS");
trustStore.load(keyStoreInputStream, "somepass".toCharArray());
SSLSocketFactory sslSocketFactory = new SSLSocketFactory(trustStore);
sslSocketFactory.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
return sslSocketFactory.connectSocket(sslSocketFactory.createSocket(), host, port, null, 0, new BasicHttpParams());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.