|
1 | 1 | /* |
2 | | - * Copyright (C) 2001-2023 Food and Agriculture Organization of the |
| 2 | + * Copyright (C) 2001-2025 Food and Agriculture Organization of the |
3 | 3 | * United Nations (FAO-UN), United Nations World Food Programme (WFP) |
4 | 4 | * and United Nations Environment Programme (UNEP) |
5 | 5 | * |
|
31 | 31 | import co.elastic.clients.elasticsearch._types.query_dsl.WrapperQuery; |
32 | 32 | import co.elastic.clients.elasticsearch.cluster.HealthResponse; |
33 | 33 | import co.elastic.clients.elasticsearch.core.*; |
34 | | -import co.elastic.clients.elasticsearch.core.search.Hit; |
35 | 34 | import co.elastic.clients.elasticsearch.indices.AnalyzeRequest; |
36 | 35 | import co.elastic.clients.elasticsearch.indices.AnalyzeResponse; |
37 | 36 | import co.elastic.clients.elasticsearch.indices.analyze.AnalyzeToken; |
@@ -148,17 +147,19 @@ public boolean isTrusted(X509Certificate[] arg0, String arg1) throws Certificate |
148 | 147 | credentialsProvider.setCredentials(AuthScope.ANY, |
149 | 148 | new UsernamePasswordCredentials(username, password)); |
150 | 149 |
|
151 | | - builder.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setSSLContext(sslContext).setDefaultCredentialsProvider(credentialsProvider)); |
| 150 | + builder.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.useSystemProperties().setSSLContext(sslContext).setDefaultCredentialsProvider(credentialsProvider)); |
152 | 151 | } else { |
153 | | - builder.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setSSLContext(sslContext)); |
| 152 | + builder.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.useSystemProperties().setSSLContext(sslContext)); |
154 | 153 | } |
155 | 154 | } else { |
156 | 155 | if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) { |
157 | 156 | final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); |
158 | 157 | credentialsProvider.setCredentials(AuthScope.ANY, |
159 | 158 | new UsernamePasswordCredentials(username, password)); |
160 | 159 |
|
161 | | - builder.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)); |
| 160 | + builder.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.useSystemProperties().setDefaultCredentialsProvider(credentialsProvider)); |
| 161 | + } else { |
| 162 | + builder.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.useSystemProperties()); |
162 | 163 | } |
163 | 164 | } |
164 | 165 |
|
@@ -381,7 +382,7 @@ public String deleteByQuery(String index, String query) throws Exception { |
381 | 382 | deleteByQueryResponse.failures().forEach(f -> stringBuilder.append(f.toString())); |
382 | 383 |
|
383 | 384 | throw new IOException(String.format( |
384 | | - "Error during removal. Errors are '%s'.", stringBuilder.toString() |
| 385 | + "Error during removal. Errors are '%s'.", stringBuilder |
385 | 386 | )); |
386 | 387 | } |
387 | 388 | } |
|
0 commit comments