# I want to use spark to read data from es, but I don't know what es.net.ssl.keystore.pass is

**URL:** <https://discuss.elastic.co/t/i-want-to-use-spark-to-read-data-from-es-but-i-dont-know-what-es-net-ssl-keystore-pass-is/335210>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [June 5, 2023, 11:53am UTC](https://discuss.elastic.co/t/i-want-to-use-spark-to-read-data-from-es-but-i-dont-know-what-es-net-ssl-keystore-pass-is/335210 "2023-06-05T11:53:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaorui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gaorui/32/125829_2.png) [@gaorui](https://discuss.elastic.co/u/gaorui)\
**Post date:** [June 5, 2023, 11:53am UTC](https://discuss.elastic.co/t/i-want-to-use-spark-to-read-data-from-es-but-i-dont-know-what-es-net-ssl-keystore-pass-is/335210/1 "2023-06-05T11:53:24Z")

</div>

When I built the es cluster, I used bin/elasticsearch-certutil to generate the CA certificate and p12 certificate, but I did not enter the password, but chose to press Enter directly.  
When I want to use spark to connect to es, I find that he needs my es.net.ssl.keystore.pass, I set it to an empty string, but an error is reported. So I'm wondering if there is a default value, or how much I should enter

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [June 5, 2023, 1:33pm UTC](https://discuss.elastic.co/t/i-want-to-use-spark-to-read-data-from-es-but-i-dont-know-what-es-net-ssl-keystore-pass-is/335210/2 "2023-06-05T13:33:45Z")

</div>

Hi @gaorui,

What is the error that you're receiving?

---

<div class="post-metadata">

**Author:** ![gaorui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gaorui/32/125829_2.png) [@gaorui](https://discuss.elastic.co/u/gaorui)\
**Post date:** [June 6, 2023, 1:10am UTC](https://discuss.elastic.co/t/i-want-to-use-spark-to-read-data-from-es-but-i-dont-know-what-es-net-ssl-keystore-pass-is/335210/3 "2023-06-06T01:10:53Z")

</div>

Hello. The es I use is version 8.5.3, and the certificate is automatically generated at startup. Here is my configuration:

```auto
        properties.put("es.net.ssl", "true");
        properties.put("es.net.ssl.keystore.location", "file:/mypath/conf/http.p12");
        properties.put("es.net.ssl.keystore.pass", "");
        properties.put("es.net.ssl.keystore.type", "PKCS12");

```

This is the error stack displayed by spark：

```auto
Exception in thread "main" org.elasticsearch.hadoop.EsHadoopIllegalArgumentException: Cannot detect ES version - typically this happens if the network/Elasticsearch cluster is not accessible or when targeting a WAN/Cloud instance without the proper setting 'es.nodes.wan.only'
	at org.elasticsearch.hadoop.rest.InitializationUtils.discoverClusterInfo(InitializationUtils.java:403)
	at org.elasticsearch.spark.sql.ElasticsearchRelation.cfg$lzycompute(DefaultSource.scala:234)
	at org.elasticsearch.spark.sql.ElasticsearchRelation.cfg(DefaultSource.scala:231)
	at org.elasticsearch.spark.sql.ElasticsearchRelation.lazySchema$lzycompute(DefaultSource.scala:238)
	at org.elasticsearch.spark.sql.ElasticsearchRelation.lazySchema(DefaultSource.scala:238)
	at org.elasticsearch.spark.sql.ElasticsearchRelation.$anonfun$schema$1(DefaultSource.scala:242)
	at scala.Option.getOrElse(Option.scala:189)
	at org.elasticsearch.spark.sql.ElasticsearchRelation.schema(DefaultSource.scala:242)
	at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:434)
	at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:229)
	at org.apache.spark.sql.DataFrameReader.$anonfun$load$2(DataFrameReader.scala:211)
	at scala.Option.getOrElse(Option.scala:189)
	at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:211)
	at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:186)
	at com.asiainfo.lcims.lcbmi.pcdnanalyze.main.NetFlowTraceBySpark.main(NetFlowTraceBySpark.java:98)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
	at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:1020)
	at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:192)
	at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:215)
	at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:91)
	at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1111)
	at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1120)
	at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: org.elasticsearch.hadoop.EsHadoopIllegalStateException: Cannot initialize SSL - Get Key failed: Cannot read the array length because "password" is null
	at org.elasticsearch.hadoop.rest.commonshttp.SSLSocketFactory.createSSLContext(SSLSocketFactory.java:175)
	at org.elasticsearch.hadoop.rest.commonshttp.SSLSocketFactory.getSSLContext(SSLSocketFactory.java:160)
	at org.elasticsearch.hadoop.rest.commonshttp.SSLSocketFactory.createSocket(SSLSocketFactory.java:129)
	at org.elasticsearch.hadoop.thirdparty.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706)
	at org.elasticsearch.hadoop.thirdparty.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386)
	at org.elasticsearch.hadoop.thirdparty.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
	at org.elasticsearch.hadoop.thirdparty.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
	at org.elasticsearch.hadoop.thirdparty.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
	at org.elasticsearch.hadoop.rest.commonshttp.CommonsHttpTransport.doExecute(CommonsHttpTransport.java:717)
	at org.elasticsearch.hadoop.rest.commonshttp.CommonsHttpTransport.access$200(CommonsHttpTransport.java:98)
	at org.elasticsearch.hadoop.rest.commonshttp.CommonsHttpTransport$2.run(CommonsHttpTransport.java:684)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
	at java.base/javax.security.auth.Subject.doAs(Subject.java:439)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1878)
	at org.elasticsearch.hadoop.mr.security.HadoopUser.doAs(HadoopUser.java:66)
	at org.elasticsearch.hadoop.rest.commonshttp.CommonsHttpTransport.execute(CommonsHttpTransport.java:681)
	at org.elasticsearch.hadoop.rest.NetworkClient.execute(NetworkClient.java:116)
	at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:442)
	at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:438)
	at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:406)
	at org.elasticsearch.hadoop.rest.RestClient.mainInfo(RestClient.java:755)
	at org.elasticsearch.hadoop.rest.InitializationUtils.discoverClusterInfo(InitializationUtils.java:393)
	... 26 more
Caused by: java.security.UnrecoverableKeyException: Get Key failed: Cannot read the array length because "password" is null
	at java.base/sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:450)
	at java.base/sun.security.util.KeyStoreDelegator.engineGetKey(KeyStoreDelegator.java:91)
	at java.base/java.security.KeyStore.getKey(KeyStore.java:1050)
	at java.base/sun.security.ssl.SunX509KeyManagerImpl.<init>(SunX509KeyManagerImpl.java:141)
	at java.base/sun.security.ssl.KeyManagerFactoryImpl$SunX509.engineInit(KeyManagerFactoryImpl.java:64)
	at java.base/javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:275)
	at org.elasticsearch.hadoop.rest.commonshttp.SSLSocketFactory.loadKeyManagers(SSLSocketFactory.java:217)
	at org.elasticsearch.hadoop.rest.commonshttp.SSLSocketFactory.createSSLContext(SSLSocketFactory.java:173)
	... 47 more
Caused by: java.lang.NullPointerException: Cannot read the array length because "password" is null
	at java.base/sun.security.pkcs12.PKCS12KeyStore$RetryWithZero.run(PKCS12KeyStore.java:259)
	at java.base/sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:361)
	... 54 more

```

Looks like the password cannot be null

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [June 6, 2023, 7:58am UTC](https://discuss.elastic.co/t/i-want-to-use-spark-to-read-data-from-es-but-i-dont-know-what-es-net-ssl-keystore-pass-is/335210/4 "2023-06-06T07:58:51Z")

</div>

Yes the password can't be null so I would recommend setting up a password and checking your settings.

---

<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:** [July 4, 2023, 7:59am UTC](https://discuss.elastic.co/t/i-want-to-use-spark-to-read-data-from-es-but-i-dont-know-what-es-net-ssl-keystore-pass-is/335210/5 "2023-07-04T07:59:27Z")

</div>

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