Created
November 28, 2011 03:37
-
-
Save moxie0/1398990 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 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