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/09 09:08:45 UTC
[camel] 01/03: CAMEL-15280 - Camel-AWS2-*: Add the ability to trust
all certificates when overidding the endpoint - IAM
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 87c043eaa8df1b4e2ba758b7c36e48cd3782ef36
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jul 9 10:49:58 2020 +0200
CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - IAM
---
.../apache/camel/component/aws2/iam/IAM2Configuration.java | 13 +++++++++++++
.../org/apache/camel/component/aws2/iam/IAM2Endpoint.java | 13 +++++++++++++
2 files changed, 26 insertions(+)
diff --git a/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java
index 12e99bf..a394abd 100644
--- a/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java
+++ b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Configuration.java
@@ -49,6 +49,8 @@ public class IAM2Configuration implements Cloneable {
private String region;
@UriParam(defaultValue = "false")
private boolean pojoRequest;
+ @UriParam(defaultValue = "false")
+ private boolean trustAllCertificates;
public IamClient getIamClient() {
return iamClient;
@@ -151,6 +153,17 @@ public class IAM2Configuration 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-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
index bcef11a..fd61b6e 100644
--- a/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.java
+++ b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Endpoint.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.iam.IamClient;
import software.amazon.awssdk.services.iam.IamClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
/**
* Manage AWS IAM instances using AWS SDK version 2.x.
@@ -114,6 +117,16 @@ public class IAM2Endpoint 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;
}