Configuring SSL
Configuring the library to support SSL is simple. By default you don't have to configure anything if you don't need to use your own certificates etc.
AsyncHttpClient client = new AsyncHttpClient(); Response response = client.prepareGet(("https://sonatype.com").execute().get();
The library will detect it's an SSL request and appropriately locate the key store, trust store etc. If you need to configure those objects, all you need to do is to create an SSLContext and set it using the AsyncHttpClient's Builder as showed below:
InputStream keyStoreStream = .... char[] keyStorePassword = "changeit".toCharArray(); KeyStore ks = KeyStore.getInstance("JKS"); ks.load(keyStoreStream, keyStorePassword); char[] certificatePassword = "changeit".toCharArray(); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, certificatePassword); KeyManager[] keyManagers = kmf.getKeyManagers(); TrustManager[] trustManagers = new TrustManager[]{DUMMY_TRUST_MANAGER}; SecureRandom secureRandom = new SecureRandom(); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(keyManagers, trustManagers, secureRandom); Builder builder = new AsyncHttpClientConfig.Builder(); builder.setSSLContext(myOwnThreadPool); AsyncHttpClient client = new AsyncHttpClient(builder.build());