You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/10/16 12:53:15 UTC

[GitHub] [druid] awelsh93 commented on a change in pull request #9938: Add https to druid-influxdb-emitter extension

awelsh93 commented on a change in pull request #9938:
URL: https://github.com/apache/druid/pull/9938#discussion_r506382581



##########
File path: extensions-contrib/influxdb-emitter/src/main/java/org/apache/druid/emitter/influxdb/InfluxdbEmitter.java
##########
@@ -211,4 +219,46 @@ public void transformAndSendToInfluxdb(LinkedBlockingQueue<ServiceMetricEvent> e
     postToInflux(payload.toString());
   }
 
+  private HttpClient buildInfluxdbClient()
+  {
+    if ("https".equals(influxdbEmitterConfig.getProtocol())) {
+      SSLContext sslContext;
+      if (influxdbEmitterConfig.getTrustStorePath() == null || influxdbEmitterConfig.getTrustStorePassword() == null) {
+        String msg = "Can't load TrustStore. Truststore path or password is not set.";
+        log.error(msg);
+        throw new IllegalStateException(msg);
+      }
+
+      FileInputStream in = null;
+
+      try {
+        in = new FileInputStream(new File(influxdbEmitterConfig.getTrustStorePath()));
+        KeyStore store = KeyStore.getInstance(influxdbEmitterConfig.getTrustStoreType());
+        store.load(in, influxdbEmitterConfig.getTrustStorePassword().toCharArray());
+        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+        tmf.init(store);
+        sslContext = SSLContext.getInstance("TLS");
+        sslContext.init(null, tmf.getTrustManagers(), null);
+      }
+      catch (Exception ex) {
+        String msg = "Unable to load TrustStore";
+        log.error(msg);
+        throw new IllegalStateException(msg);
+      }
+      finally {
+        if (in != null) {

Review comment:
       Thanks for your review - I think I've addressed these comments. Can you take another look please?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org