Skip to content

Instantly share code, notes, and snippets.

@robmadden
Last active December 23, 2015 10:49
Show Gist options
  • Save robmadden/6624145 to your computer and use it in GitHub Desktop.
Save robmadden/6624145 to your computer and use it in GitHub Desktop.
Loopj cert example
AsyncHttpClient client = new AsyncHttpClient();
if (MainActivity.DEVELOPER_MODE) {
try {
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
trustStore.load(null, null);
final SSLSocketFactory sf = CustomSSLSocketFactory.getSSLSocketFactory(context);
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
client.setSSLSocketFactory(sf);
} catch (final Exception e) {
Log.d(TAG, "Failed to create keystore");
}
}
final String url = getSafeUrl();
final RequestParams params = getParameters();
Log.d(TAG, new StringBuilder("POST REQUEST: ").append(url).append(" with params: ").append(params.toString()).toString());
client.post(context, url, params, createAsyncResponseListener());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment