RestHighLevelClient java client

How can I use the RestHighLevelClient java client with Open Distro for Elasticsearch?

My code is:

final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(“admin”, “admin”));
RestClientBuilder restClientBuilder = RestClient.builder(httpHosts);
restClientBuilder.setHttpClientConfigCallback(httpClientBuilder →
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
this.restClient = new RestHighLevelClient(restClientBuilder);

When I try to do a search I got the error:
“exception”: “javax.net.ssl.SSLHandshakeException”,
“message”: “General SSLEngine problem”

There are anyone that can give me an help?

Thank you

Hi did u manage to figure this out?
I spent (wasted) 2 days and still couldn’t get either the Java RestHighLevelClient or the Java TCP Transport client working with the Security enabled (using demo ssl certs).

For now I was just able to get round the issue by using the elasticdump tool (security is still enabled):
elasticdump --input=“my data” --output=https://admin:admin@“my ip”:9200/“my index” --insecure --type=data

Hi all, I was able to get this working without too much fuss. I ran into the same handshake exception until I got the certificate working with Java. Sample code here: Open Distro Java High Level REST Client · Issue #64 · opendistro-for-elasticsearch/sample-code · GitHub

1 Like

Hi @aetter,

Is there a library for Security - Access Control. Elastic RestHighLevelClient point to /_security/role. Is there a different library for opendistro ?

GET _opendistro/_security/api/roles/

Hi @mkiran18, no, there’s no high-level client for ODFE functions, but you can use the low-level Java REST client to send requests to arbitrary URIs (such as GET or PUT to _opendistro/_security/api/roles).