Java Client encrypted communication Doc bug

The Encrypted communication example in Java REST Client section is completely wrong.
The original ref:

Here is what should be there:

    KeyStore keystore = KeyStore.getInstance("jks");
    try (InputStream is = Files.newInputStream(keyStorePath)) {
        keystore.load(is, keyStorePass.toCharArray());
    SSLContextBuilder sslBuilder = SSLContexts.custom()
        . loadKeyMaterial (keystore, null);
    final SSLContext sslContext =;
    RestClientBuilder builder = RestClient.builder(
        new HttpHost("localhost", 9200, "https"))
        .setHttpClientConfigCallback(new HttpClientConfigCallback() {
            public HttpAsyncClientBuilder customizeHttpClient(
                    HttpAsyncClientBuilder httpClientBuilder) {
                return httpClientBuilder.setSSLContext(sslContext);

Can you please create a bug report at

I don't follow what you think is wrong about that example.

It is configuring a custom SSL context using a truststore as an example of connecting to an Elasticsearch node that uses a certificate from a non-standard CA.

Your example demonstrates how to provide a keystore, which is what you would need if you wish to connect to a node that requires client SSL certificates (PKI).
That's a valid example, but it's simply a different example than the one that is there. It doesn't mean that the existing example is wrong.

You could certainly make an argument that the example could have more explanation around it, but replacing it with a different example doesn't help that.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.