0

everyone , I am using elasticsearch 6.8.22 and I need to enable the https for it I have done setting of secure the elasticsearch and can connect to https://localhost:9200/_cat/indices?v , it require user login , then I already set the user password and can login the elastic search enter image description here

but when I use java rest client to connect elastic search , it throw such error

{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request

I am using RestHighLevelClient and the elastic jar version is 6.5.4, the certification of elastic search already install into my java client, I think it's because I need to add the elasticsearch user and password into java client , is there anyone knows about this or whether we can skip to authorize the user when java client call elastic search ?

Here is my elastic search https setting

xpack.security.enabled : true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: D:/App/elasticsearch-6.8.22/config/certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: D:/App/elasticsearch-6.8.22/config/certs/elastic-certificates.p12

xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: D:/App/elasticsearch-6.8.22/config/certs/elastic-certificates.p12
xpack.security.http.ssl.truststore.path: D:/App/elasticsearch-6.8.22/config/certs/elastic-certificates.p12
mres
  • 53
  • 2
  • 6
  • Have you set up Api keys ? – Paulo Dec 24 '21 at 07:54
  • I only import elastic search certification into jkd , anyway , thanks for your response , I resolved the problem by following this way https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/7.16/_basic_authentication.html – mres Dec 27 '21 at 01:44

1 Answers1

-1

resolved the problem by following way

  1. in the <es_folder>/bin run cmd : elasticsearch-setup-passwords interactive to set elastic search user password
  2. apply following changes https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/7.16/_basic_authentication.html
mres
  • 53
  • 2
  • 6
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 27 '21 at 04:25