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 4592e57466e7839be3b3bcf6bf195ccdb69a9f59 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Jul 9 11:28:04 2020 +0200 CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - Kinesis --- .../camel/component/aws2/kinesis/Kinesis2Configuration.java | 10 ++++++++++ .../camel/component/aws2/kinesis/Kinesis2Endpoint.java | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Configuration.java b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Configuration.java index dff2092..ca5e668 100644 --- a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Configuration.java +++ b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Configuration.java @@ -59,6 +59,8 @@ public class Kinesis2Configuration implements Cloneable { private String proxyHost; @UriParam(description = "To define a proxy port when instantiating the Kinesis client") private Integer proxyPort; + @UriParam(defaultValue = "false", description = "If we want to trust all certificates in case of overriding the endpoint") + private boolean trustAllCertificates; public KinesisClient getAmazonKinesisClient() { return amazonKinesisClient; @@ -163,6 +165,14 @@ public class Kinesis2Configuration implements Cloneable { public void setProxyPort(Integer proxyPort) { this.proxyPort = proxyPort; } + + public boolean isTrustAllCertificates() { + return trustAllCertificates; + } + + public void setTrustAllCertificates(boolean trustAllCertificates) { + this.trustAllCertificates = trustAllCertificates; + } // ************************************************* // diff --git a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Endpoint.java b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Endpoint.java index 4549a44..c4feafb 100644 --- a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Endpoint.java +++ b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Endpoint.java @@ -29,6 +29,8 @@ 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; @@ -36,6 +38,7 @@ import software.amazon.awssdk.services.kinesis.KinesisClient; import software.amazon.awssdk.services.kinesis.KinesisClientBuilder; import software.amazon.awssdk.services.kinesis.model.Record; import software.amazon.awssdk.services.kinesis.model.ShardIteratorType; +import software.amazon.awssdk.utils.AttributeMap; /** * Consume and produce records from and to AWS Kinesis Streams using AWS SDK version 2.x. @@ -132,6 +135,16 @@ public class Kinesis2Endpoint 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; }