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 11:05:40 UTC
[camel] 01/03: CAMEL-15280 - Camel-AWS2-*: Add the ability to trust
all certificates when overidding the endpoint - MQ
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 27edffabf98be2ac4a11fc4b9abbfeebdb93a3d4
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jul 9 13:03:56 2020 +0200
CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - MQ
---
.../apache/camel/component/aws2/mq/MQ2Configuration.java | 13 +++++++++++++
.../org/apache/camel/component/aws2/mq/MQ2Endpoint.java | 13 +++++++++++++
2 files changed, 26 insertions(+)
diff --git a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
index 2128ab2..c990ccf 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Configuration.java
@@ -49,6 +49,8 @@ public class MQ2Configuration implements Cloneable {
private String region;
@UriParam(defaultValue = "false")
private boolean pojoRequest;
+ @UriParam(defaultValue = "false")
+ private boolean trustAllCertificates;
public MqClient getAmazonMqClient() {
return amazonMqClient;
@@ -151,6 +153,17 @@ public class MQ2Configuration 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-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Endpoint.java b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Endpoint.java
index 12770e3..60adfda 100644
--- a/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Endpoint.java
+++ b/components/camel-aws2-mq/src/main/java/org/apache/camel/component/aws2/mq/MQ2Endpoint.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.mq.MqClient;
import software.amazon.awssdk.services.mq.MqClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
/**
* Manage AWS MQ instances using AWS SDK version 2.x.
@@ -114,6 +117,16 @@ public class MQ2Endpoint 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;
}