apache / apache/beam

SSL authentication key set to trustMaterial instead of keyMaterial

Open
#20,525 0 comments 0 reactions 0 assignees View on GitHub
bug elasticsearch io java P3
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

If I set
ElasticsearchIO.ConnectionConfiguration#withKeystorePath
the keystore is set to trustMaterial which I think is wrong, because this keystore is suppose to be truststore for certificates.

So if I use keyStoreKey instead of username and pass:
```

ElasticsearchIO.write()
.withConnectionConfiguration(
ElasticsearchIO.ConnectionConfiguration

.create(config.addresses().toArray(new String[0]), config.index(), config.type())
.withKeystorePath(config.keystorePath())

.withKeystorePassword("somepassword")
.withTrustSelfSignedCerts(true));

```

I cannot authenticate.

I got
```

Caused by: javax.net.ssl.SSLException: Received fatal alert: bad_certificate

```

because the authetication key is set to trustMaterial instead of keyMaterial

```

SSLContexts.custom().loadTrustMaterial(keyStore, trustStrategy).build();

```

via [code](https://github.com/apache/beam/blob/release-2.19.0/sdks/java/io/elasticsearch/src/main/java/org/apache/beam/sdk/io/elasticsearch/ElasticsearchIO.java#L439)

I am working on fix

Imported from Jira [BEAM-10723](https://issues.apache.org/jira/browse/BEAM-10723). Original Jira may contain additional context.
Reported by: marek.simunek.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.