Couldn't instantiate rest high level client when the cluster is secured with searchguard and ssl is enabled for the http layer

Hey, Guys i have a cluster which is running with elasticsearch 5.6.2, and it has searchguard plugin enabled, also SSL is enabled for both the transport layer as well as the http layer, when i execute the following curl command from the terminal
curl -k -u user:password https://localhost:9200, the response is returned and its fine, but when i instantiate a high level rest client using the following code

    public RccRestClient()
    throws NodeValidationException, IOException, CertificateException, NoSuchAlgorithmException,
    KeyStoreException, KeyManagementException, UnrecoverableKeyException {
    SSLContextBuilder sslBuilder = SSLContexts.custom()
        //.loadTrustMaterial(new File("/Users/kumard/Desktop/elasticsearch-5.6.2/config/truststore.jks"),"password".toCharArray());
                .loadKeyMaterial(new File("/Users/kumard/Desktop/elasticsearch-5.6.2/config/0-keystore.jks"),"password".toCharArray(),"password".toCharArray());
    final SSLContext sslContext =;

    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
        new UsernamePasswordCredentials("user", "password"));

    Header[] defaultHeaders = new Header[] {
        new BasicHeader("Authorization", "Basic " + encodeBase64("user:password".getBytes())) };
    RestClientBuilder restClientBuilder = RestClient
        .builder(new HttpHost("localhost",
            Integer.valueOf("9200"), "https"))
        .setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
            public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
//                .setHttpClientConfigCallback(
//                new RestClientBuilder.HttpClientConfigCallback() {
//                    @Override

// public HttpAsyncClientBuilder customizeHttpClient(
// HttpAsyncClientBuilder httpClientBuilder) {
// httpClientBuilder.setDefaultHeaders(Arrays.asList(defaultHeaders));
// httpClientBuilder.setSSLContext(sslContext);
// return httpClientBuilder;
// }
// }
// );

    restClientBuilder.setFailureListener(new RestClient.FailureListener() {
        public void onFailure(HttpHost host) {
            LOGGER.error("Couldn't initialize Low Level Rest Client");

i am getting IO exception saying with timeouts, there is no error being logged. what is the correct way to achieve this.

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