[
https://issues.apache.org/jira/browse/BEAM-8175?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17122652#comment-17122652
]
Beam JIRA Bot commented on BEAM-8175:
-------------------------------------
This issue is P2 but has been unassigned without any comment for 60 days so it
has been labeled "stale-P2". If this issue is still affecting you, we care!
Please comment and remove the label. Otherwise, in 14 days the issue will be
moved to P3.
Please see https://beam.apache.org/contribute/jira-priorities/ for a detailed
explanation of what these priorities mean.
> Setting java keystore overrides basic auth in ElasticsearchIO connection
> configuration
> --------------------------------------------------------------------------------------
>
> Key: BEAM-8175
> URL: https://issues.apache.org/jira/browse/BEAM-8175
> Project: Beam
> Issue Type: Bug
> Components: io-java-elasticsearch
> Affects Versions: 2.15.0
> Reporter: Hemant Y Bhoyar
> Priority: P2
> Labels: stale-P2
>
> While creating the rest client in ElasticsearchIO, the
> httpClientConfigCallback is overridden by the step to set the key store.
> Making it not possible to use a custom key store with basic auth.
> {code:java}
> if (getUsername() != null) {
> final CredentialsProvider credentialsProvider = new
> BasicCredentialsProvider();
> credentialsProvider.setCredentials(
> AuthScope.ANY, new UsernamePasswordCredentials(getUsername(),
> getPassword()));
> restClientBuilder.setHttpClientConfigCallback(
> httpAsyncClientBuilder ->
> httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
> }
> if (getKeystorePath() != null && !getKeystorePath().isEmpty()) {
> try {
> KeyStore keyStore = KeyStore.getInstance("jks");
> try (InputStream is = new FileInputStream(new File(getKeystorePath()))) {
> String keystorePassword = getKeystorePassword();
> keyStore.load(is, (keystorePassword == null) ? null :
> keystorePassword.toCharArray());
> }
> final SSLContext sslContext =
> SSLContexts.custom()
> .loadTrustMaterial(keyStore, new TrustSelfSignedStrategy())
> .build();
> final SSLIOSessionStrategy sessionStrategy = new
> SSLIOSessionStrategy(sslContext);
> restClientBuilder.setHttpClientConfigCallback(
> httpClientBuilder ->
> httpClientBuilder.setSSLContext(sslContext).setSSLStrategy(sessionStrategy));
> } catch (Exception e) {
> throw new IOException("Can't load the client certificate from the
> keystore", e);
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)