Best practice to overwrite ElasticSearchConnection class

10 views
Skip to first unread message

Steven Zhu

unread,
May 18, 2021, 7:10:14 PM5/18/21
to DigitalPebble
Hi There,

I need to overwrite ElasticSearchConnection class to add SSL encrypted connection to Elasticsearch as the following:

if (needsHttps) {
try {
    FileInputStream fileInputStream = new FileInputStream(keystorePath);
    KeyStore truststore = KeyStore.getInstance("jks");
    truststore.load(fileInputStream, keystorePassword.toCharArray());
    SSLContextBuilder sslBuilder = SSLContexts.custom().loadTrustMaterial(truststore, null);
                                    SSLContext sslContext = sslBuilder.build();
                                    httpClientBuilder.setSSLContext(sslContext);
} catch  (NoSuchAlgorithmException | CertificateException | KeyManagementException | KeyStoreException e) {
_logger.error("Failed to instantiate sslcontext object: \n{}", e.getMessage());
throw new SecurityException();
} catch (IOException ioe) {
_logger.error("Failed to find keystore: \n{}", ioe.getMessage());
throw new RuntimeException();
}
    }

Thanks

Steven

Julien Nioche

unread,
May 19, 2021, 5:44:34 AM5/19/21
to DigitalPebble
Hi Steven

At the moment I am afraid you'd have to copy the whole elastic module of StormCrawler and modify that class. Other parts of the code rely on the current implementation explicitly and do not have a mechanism to specify an alternative implementation.
Feel free to open an issue on Github so that we add this functionality in a future release or allow a custom implementation of the connection class to be used.

Thanks

Julien

Steven Zhu

unread,
May 20, 2021, 3:05:12 PM5/20/21
to DigitalPebble
Hi Julien,

Thank you for the quick response. I have a bug to fix. Once I fix, I will create an issue and submit source codes with configuration changes for this functionality.

Steven

Reply all
Reply to author
Forward
0 new messages