Hi
I am using Java High Level Rest client on Spring boot to perform Search API operations.
Our Elasticsearch is protected with https and basic(user/pwd) authentication.
I'm receiving below exception ,
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Code below,
@Bean
public RestHighLevelClient initializeClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
RestClientBuilder builder = RestClient.builder(new HttpHost(host, port, "https")).setHttpClientConfigCallback(
httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
builder.setRequestConfigCallback(
new RestClientBuilder.RequestConfigCallback() {
@Override
public RequestConfig.Builder customizeRequestConfig(
RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setSocketTimeout(10000);
}
});
RestHighLevelClient client = new RestHighLevelClient(builder);
return client;
}
Do i need to do something more to connect to a https elastic search service , if so how would solution varies across dev and prod. DO i need to install ssl certificate of elasticsearch into my jvm?