# 8.2 closing connection when creating an index

**URL:** <https://discuss.elastic.co/t/8-2-closing-connection-when-creating-an-index/306972>\
**Category:** Elasticsearch\
**Created:** [June 12, 2022, 9:17pm UTC](https://discuss.elastic.co/t/8-2-closing-connection-when-creating-an-index/306972 "2022-06-12T21:17:22Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Jack\_Park](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_park/32/30787_2.png) [@Jack\_Park](https://discuss.elastic.co/u/Jack_Park)\
**Post date:** [June 14, 2022, 10:37pm UTC](https://discuss.elastic.co/t/8-2-closing-connection-when-creating-an-index/306972/5 "2022-06-14T22:37:14Z")

</div>

> [@stephenb](#):
>
> ```auto
> KeyStore trustStore = KeyStore.getInstance("pkcs12");
> trustStore.load(null, null);
> 
> ```

That's the code I entered. There's an issue with it: (null, null) should be (inputstream to the keystore, keystore password).

An example I found here

> [@Missing Authentication for REST request](https://discuss.elastic.co/t/missing-authentication-for-rest-request/154807/6):
>
> For the High Level rest client see the last comment [here](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low-usage-initialization.html) that references [HttpAsyncClientBuilder](http://hc.apache.org/httpcomponents-asyncclient-dev/httpasyncclient/apidocs/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.html) where you can pass the keystore parameter. For postman, I am not aware how this is done, you can probably find the answer in their docs.

uses "password".

I found that I needed to set the password, which I did.

Now that I, in theory, have jumped through those hoops, the example earlier said  
KeyStore trustStore = KeyStore.getInstance("pkcs12");  
whereas the example just found (albeit from an earlier date) says  
KeyStore keyStore = KeyStore.getInstance("jks");  
This example

> **[Encrypted communication | Elasticsearch Java API Client \[master\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/master/_encrypted_communication.html)**

uses pkcs12.  
That leaves me with a new error, one which comes before the authentication issue:

DerInputStream.getLength(): lengthTag=87, too big.

I am using the path to the ES keystore as the trustPath.

Google isn't very helpful on that error.

---

_[View the full topic](https://discuss.elastic.co/t/8-2-closing-connection-when-creating-an-index/306972)._
