You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/01/10 14:35:23 UTC

[camel] branch camel-3.x updated (ef2ee59afce -> 6054b57b729)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git


    from ef2ee59afce (chores) camel-irc: prevent NPE on lost connection
     new 780bd73a19f CAMEL-18773 - Camel-Elasticsearch: CertificatePath should be readable through ResourceHelper
     new f3edbdc1915 CAMEL-18773 - Camel-Elasticsearch: CertificatePath should be readable through ResourceHelper
     new 6054b57b729 CAMEL-18773 - Camel-Elasticsearch: CertificatePath should be readable through ResourceHelper

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../resources/org/apache/camel/component/es/elasticsearch.json     | 2 +-
 .../org/apache/camel/component/es/ElasticsearchConfiguration.java  | 3 ++-
 .../java/org/apache/camel/component/es/ElasticsearchProducer.java  | 7 +++++--
 .../camel/component/es/integration/ElasticsearchTestSupport.java   | 2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)


[camel] 02/03: CAMEL-18773 - Camel-Elasticsearch: CertificatePath should be readable through ResourceHelper

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f3edbdc1915c1c4d361be08fe22679eb81a1a791
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jan 10 15:06:07 2023 +0100

    CAMEL-18773 - Camel-Elasticsearch: CertificatePath should be readable through ResourceHelper
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../java/org/apache/camel/component/es/ElasticsearchConfiguration.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchConfiguration.java b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchConfiguration.java
index 34b3676ef86..5058bf75b0c 100644
--- a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchConfiguration.java
+++ b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchConfiguration.java
@@ -213,7 +213,8 @@ public class ElasticsearchConfiguration {
     }
 
     /**
-     * The path of the self-signed certificate to use to access to Elasticsearch.
+     * The certificate that can be used to access the ES Cluster.
+     * It can be loaded by default from classpath, but you can prefix with classpath:, file:, or http: to load the resource from different systems.
      */
     public String getCertificatePath() {
         return certificatePath;


[camel] 01/03: CAMEL-18773 - Camel-Elasticsearch: CertificatePath should be readable through ResourceHelper

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 780bd73a19f9f5bab7be454041cf4dceed2e4844
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jan 10 15:03:45 2023 +0100

    CAMEL-18773 - Camel-Elasticsearch: CertificatePath should be readable through ResourceHelper
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../java/org/apache/camel/component/es/ElasticsearchProducer.java  | 7 +++++--
 .../camel/component/es/integration/ElasticsearchTestSupport.java   | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java
index 5cafd7933c5..d373a2b0b9e 100644
--- a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java
+++ b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchProducer.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.es;
 
 import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.security.KeyStore;
@@ -58,6 +59,7 @@ import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.support.DefaultAsyncProducer;
+import org.apache.camel.support.ResourceHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.http.HttpHost;
 import org.apache.http.auth.AuthScope;
@@ -540,8 +542,9 @@ class ElasticsearchProducer extends DefaultAsyncProducer {
     private SSLContext createSslContextFromCa() {
         try {
             CertificateFactory factory = CertificateFactory.getInstance("X.509");
-            Certificate trustedCa = factory.generateCertificate(
-                    new ByteArrayInputStream(Files.readAllBytes(Paths.get(configuration.getCertificatePath()))));
+            InputStream resolveMandatoryResourceAsInputStream
+                    = ResourceHelper.resolveMandatoryResourceAsInputStream(getEndpoint().getCamelContext(), configuration.getCertificatePath());
+            Certificate trustedCa = factory.generateCertificate(resolveMandatoryResourceAsInputStream);
             KeyStore trustStore = KeyStore.getInstance("pkcs12");
             trustStore.load(null, null);
             trustStore.setCertificateEntry("ca", trustedCa);
diff --git a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchTestSupport.java b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchTestSupport.java
index 5257a55dbc8..efe8664c075 100644
--- a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchTestSupport.java
+++ b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchTestSupport.java
@@ -126,7 +126,7 @@ public class ElasticsearchTestSupport extends CamelTestSupport {
         elasticsearchComponent.setHostAddresses(service.getHttpHostAddress());
         elasticsearchComponent.setUser(USER_NAME);
         elasticsearchComponent.setPassword(PASSWORD);
-        elasticsearchComponent.setCertificatePath(certPath.toString());
+        elasticsearchComponent.setCertificatePath("file:" + certPath.toString());
 
         CamelContext context = super.createCamelContext();
         context.addComponent("elasticsearch", elasticsearchComponent);


[camel] 03/03: CAMEL-18773 - Camel-Elasticsearch: CertificatePath should be readable through ResourceHelper

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6054b57b7291ea7c668b68378549b05c54c69489
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jan 10 15:09:23 2023 +0100

    CAMEL-18773 - Camel-Elasticsearch: CertificatePath should be readable through ResourceHelper
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../resources/org/apache/camel/component/es/elasticsearch.json          | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-elasticsearch/src/generated/resources/org/apache/camel/component/es/elasticsearch.json b/components/camel-elasticsearch/src/generated/resources/org/apache/camel/component/es/elasticsearch.json
index dad50940657..ecc576e3e01 100644
--- a/components/camel-elasticsearch/src/generated/resources/org/apache/camel/component/es/elasticsearch.json
+++ b/components/camel-elasticsearch/src/generated/resources/org/apache/camel/component/es/elasticsearch.json
@@ -67,7 +67,7 @@
     "enableSniffer": { "kind": "parameter", "displayName": "Enable Sniffer", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.es.ElasticsearchConfiguration", "configurationField": "configuration", "description": "Enable automatically discover nodes from a running Elasticsearch cluster. If this option is us [...]
     "sniffAfterFailureDelay": { "kind": "parameter", "displayName": "Sniff After Failure Delay", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 60000, "configurationClass": "org.apache.camel.component.es.ElasticsearchConfiguration", "configurationField": "configuration", "description": "The delay of a sniff execution scheduled after a failure (in milliseconds)" },
     "snifferInterval": { "kind": "parameter", "displayName": "Sniffer Interval", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 300000, "configurationClass": "org.apache.camel.component.es.ElasticsearchConfiguration", "configurationField": "configuration", "description": "The interval between consecutive ordinary sniff executions in milliseconds. Will be honoured  [...]
-    "certificatePath": { "kind": "parameter", "displayName": "Certificate Path", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.es.ElasticsearchConfiguration", "configurationField": "configuration", "description": "The path of the self-signed certificate to use to access to Elasticsearch." },
+    "certificatePath": { "kind": "parameter", "displayName": "Certificate Path", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.es.ElasticsearchConfiguration", "configurationField": "configuration", "description": "The certificate that can be used to access the ES Cluster. It can be loaded by default from classpath, bu [...]
     "enableSSL": { "kind": "parameter", "displayName": "Enable SSL", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.es.ElasticsearchConfiguration", "configurationField": "configuration", "description": "Enable SSL" }
   }
 }