Encrypted communicationedit
Encrypted communication can also be configured through the
HttpClientConfigCallback
. The
org.apache.http.impl.nio.client.HttpAsyncClientBuilder
received as an argument exposes multiple methods to configure encrypted
communication: setSSLContext
, setSSLSessionStrategy
and
setConnectionManager
, in order of precedence from the least important.
The following is an example:
KeyStore keyStore = KeyStore.getInstance("jks"); try (InputStream is = Files.newInputStream(keyStorePath)) { keyStore.load(is, keyStorePass.toCharArray()); } RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)) .setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { @Override public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { return httpClientBuilder.setSSLContext(sslcontext); } }) .build();