# Missing Authentication for REST request

**URL:** <https://discuss.elastic.co/t/missing-authentication-for-rest-request/154807>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [October 31, 2018, 10:12am UTC](https://discuss.elastic.co/t/missing-authentication-for-rest-request/154807 "2018-10-31T10:12:37Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [November 5, 2018, 2:30pm UTC](https://discuss.elastic.co/t/missing-authentication-for-rest-request/154807/21 "2018-11-05T14:30:46Z")

</div>

Hi again.

Sorry but this feels like we're troubleshooting your code now and I don't know how much of help I Can be with that. Please make sure that your code is functional so that we can focus on the SSL client authentication with Elasticsearch.

- Above, I've asked you to this process for your `keystore`, you did that for your `truststore`
- You removed `.loadKeyMaterial` from your code now so your client doesn't have the key and certificate it needs to authenticate to Elasticseach. You should call `.loadKeyMaterial` with the `keystore` that you would create following my instructions above.

---

<div class="post-metadata">

**Author:** ![Calvin-J-Scott](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/calvin-j-scott/32/37302_2.png) [@Calvin-J-Scott](https://discuss.elastic.co/u/Calvin-J-Scott)\
**Post date:** [November 5, 2018, 2:43pm UTC](https://discuss.elastic.co/t/missing-authentication-for-rest-request/154807/22 "2018-11-05T14:43:49Z")

</div>

Hi i removed them bits to be inline with the documentation at [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/\_encrypted\_communication.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_encrypted_communication.html)

---

<div class="post-metadata">

**Author:** ![Calvin-J-Scott](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/calvin-j-scott/32/37302_2.png) [@Calvin-J-Scott](https://discuss.elastic.co/u/Calvin-J-Scott)\
**Post date:** [November 5, 2018, 3:45pm UTC](https://discuss.elastic.co/t/missing-authentication-for-rest-request/154807/23 "2018-11-05T15:45:07Z")

</div>

Thank you for you help taking a few steps back and redoing the truststore and keystore from scratch alongside your last few comments got it working

---

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [November 5, 2018, 3:58pm UTC](https://discuss.elastic.co/t/missing-authentication-for-rest-request/154807/24 "2018-11-05T15:58:47Z")

</div>

> [@Calvin-J-Scott](#):
>
> Hi i removed them bits to be inline with the documentation at [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/\_encrypted\_communication.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_encrypted_communication.html)

This configuration is about setting the truststore with the appropriate trusted certificates on the client side so that the client can verify the certificate that Elasticsearch is presenting for TLS.  
In your case, you needed to call `loadKeyMaterial` on your SSLContext so that the `HttpClient` can use the keystore in order to select the key and certificate to use for TLS client authentication. We will attempt to make this slightly clearer in our docs, thanks for your feedback!

Glad you got it working in the end 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 3, 2018, 3:58pm UTC](https://discuss.elastic.co/t/missing-authentication-for-rest-request/154807/25 "2018-12-03T15:58:47Z")

</div>

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

[Previous page](https://discuss.elastic.co/t/missing-authentication-for-rest-request/154807.md?page=1)
