New Java API with Credentials and SSL certificates

To connect to new Java API, this url:

https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/8.1/connecting.html

explains to do this :

// Create the low-level client
RestClient restClient = RestClient.builder(
    new HttpHost("localhost", 9200)).build();

// Create the transport with a Jackson mapper
ElasticsearchTransport transport = new RestClientTransport(
    restClient, new JacksonJsonpMapper());

// And create the API client
ElasticsearchClient client = new ElasticsearchClient(transport);

I guess that this example is on an unsecured cluster. bad ! bad ! bad! :wink:

From ES 8, It is mandatory to have clusters being secured with SSL dialog certificate: elastic-certificates.p12 and elastic-stack-ca.p12

Could you provide, please, a code snippet to show humanity How to connect to ES8, using Java API 8.1 and providing Credentials + SSL certificates

This would be very helpful, waiting for the official documentation.

Hey,

There is a paragraph in the RestClient documentation: Encrypted communication | Elasticsearch Java API Client [8.1] | Elastic

There is also a blog post showing how to set this up, using testcontainers, where you can probably still some code snippets: Running Elasticsearch 8.0 with Testcontainers

hope this helps!

1 Like

OK, I did not make the link between what was kept from Java Low Level REST and new Java API .

Frankly, I am so confused and lost in the new Java API that I do not recollate everything.

Thanks for the explanations.

1 Like

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