use of com.loopj.android.http.sample.util.SecureSocketFactory in project android-async-http by loopj.
the class CustomCASample method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
InputStream is = null;
try {
// Configure the library to use a custom 'bks' file to perform
// SSL negotiation.
KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType());
is = getResources().openRawResource(R.raw.store);
store.load(is, STORE_PASS.toCharArray());
getAsyncHttpClient().setSSLSocketFactory(new SecureSocketFactory(store, STORE_ALIAS));
} catch (IOException e) {
throw new KeyStoreException(e);
} catch (CertificateException e) {
throw new KeyStoreException(e);
} catch (NoSuchAlgorithmException e) {
throw new KeyStoreException(e);
} catch (KeyManagementException e) {
throw new KeyStoreException(e);
} catch (UnrecoverableKeyException e) {
throw new KeyStoreException(e);
} finally {
AsyncHttpClient.silentCloseInputStream(is);
}
} catch (KeyStoreException e) {
Log.e(LOG_TAG, "Unable to initialize key store", e);
showCustomCAHelp();
}
}
Aggregations