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 63ff9922b6d4f34e32c8a5be5c8db3641e862e0d Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Wed Jul 8 12:16:33 2020 +0200 CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - DynamoDB --- .../apache/camel/component/aws2/ddb/Ddb2Configuration.java | 13 +++++++++++++ .../org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java index b38623b..31f46f6 100644 --- a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java +++ b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Configuration.java @@ -56,6 +56,8 @@ public class Ddb2Configuration implements Cloneable { private Integer proxyPort; @UriParam private String region; + @UriParam(defaultValue = "false") + private boolean trustAllCertificates; public String getAccessKey() { return accessKey; @@ -216,6 +218,17 @@ public class Ddb2Configuration implements Cloneable { public void setRegion(String region) { this.region = region; } + + 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-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java index e510f3f..f88cedb 100644 --- a/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java +++ b/components/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/Ddb2Endpoint.java @@ -32,6 +32,8 @@ import org.slf4j.LoggerFactory; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; import software.amazon.awssdk.awscore.exception.AwsServiceException; +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; @@ -44,6 +46,7 @@ import software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughput; import software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException; import software.amazon.awssdk.services.dynamodb.model.TableDescription; import software.amazon.awssdk.services.dynamodb.model.TableStatus; +import software.amazon.awssdk.utils.AttributeMap; /** * Store and retrieve data from AWS DynamoDB service using AWS SDK version 2.x. @@ -156,6 +159,16 @@ public class Ddb2Endpoint 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; }