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 2020/07/08 12:09:10 UTC

[camel] 01/03: CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - EKS

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

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

commit 41395bc0386303ac81fc97de84cf1f3d41b29a5e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jul 8 14:07:25 2020 +0200

    CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - EKS
---
 .../apache/camel/component/aws2/eks/EKS2Configuration.java  | 13 +++++++++++++
 .../org/apache/camel/component/aws2/eks/EKS2Endpoint.java   | 13 +++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Configuration.java b/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Configuration.java
index 53428be..47fed6f 100644
--- a/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Configuration.java
+++ b/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Configuration.java
@@ -49,6 +49,8 @@ public class EKS2Configuration implements Cloneable {
     private String region;
     @UriParam(defaultValue = "false")
     private boolean pojoRequest;
+    @UriParam(defaultValue = "false")
+    private boolean trustAllCertificates;
 
     public EksClient getEksClient() {
         return eksClient;
@@ -151,6 +153,17 @@ public class EKS2Configuration implements Cloneable {
     public void setPojoRequest(boolean pojoRequest) {
         this.pojoRequest = pojoRequest;
     }
+    
+    public boolean isTrustAllCertificates() {
+        return trustAllCertificates;
+    }
+
+    /**
+     * If we want to trust all certificates in case of overriding the endpoint
+     */
+    public void setTrustAllCertificates(boolean trustAllCertificates) {
+        this.trustAllCertificates = trustAllCertificates;
+    }
 
     // *************************************************
     //
diff --git a/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Endpoint.java b/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Endpoint.java
index febd15b..ccf5828 100644
--- a/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Endpoint.java
+++ b/components/camel-aws2-eks/src/main/java/org/apache/camel/component/aws2/eks/EKS2Endpoint.java
@@ -29,11 +29,14 @@ import org.apache.camel.support.ScheduledPollEndpoint;
 import org.apache.camel.util.ObjectHelper;
 import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
 import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.http.SdkHttpClient;
+import software.amazon.awssdk.http.SdkHttpConfigurationOption;
 import software.amazon.awssdk.http.apache.ApacheHttpClient;
 import software.amazon.awssdk.http.apache.ProxyConfiguration;
 import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.eks.EksClient;
 import software.amazon.awssdk.services.eks.EksClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
 
 /**
  * Manage AWS EKS cluster instances using AWS SDK version 2.x.
@@ -114,6 +117,16 @@ public class EKS2Endpoint extends ScheduledPollEndpoint {
         if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
             clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
         }
+        if (configuration.isTrustAllCertificates()) {
+            SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap
+                    .builder()
+                    .put(
+                            SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
+                            Boolean.TRUE
+                    )
+                    .build());
+            clientBuilder.httpClient(ahc);
+        }
         client = clientBuilder.build();
         return client;
     }