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 71fffa44d37b87d33472d193d7c88ee08c1c7df2 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Jul 9 11:24:52 2020 +0200 CAMEL-15280 - Camel-AWS2-*: Add the ability to trust all certificates when overidding the endpoint - Kinesis Firehose --- .../aws2/firehose/KinesisFirehose2Configuration.java | 12 +++++++++++- .../component/aws2/firehose/KinesisFirehose2Endpoint.java | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Configuration.java b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Configuration.java index 3c6b5d2..7ad41cd 100644 --- a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Configuration.java +++ b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Configuration.java @@ -46,7 +46,9 @@ public class KinesisFirehose2Configuration implements Cloneable { @UriParam(description = "To define a proxy port when instantiating the Kinesis Firehose client") private Integer proxyPort; @UriParam(label = "producer", description = "The operation to do in case the user don't want to send only a record") - private KinesisFirehose2Operations operation; + private KinesisFirehose2Operations operation; + @UriParam(defaultValue = "false", description = "If we want to trust all certificates in case of overriding the endpoint") + private boolean trustAllCertificates; public void setAmazonKinesisFirehoseClient(FirehoseClient client) { this.amazonKinesisFirehoseClient = client; @@ -119,6 +121,14 @@ public class KinesisFirehose2Configuration implements Cloneable { public void setOperation(KinesisFirehose2Operations operation) { this.operation = operation; } + + 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/firehose/KinesisFirehose2Endpoint.java b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Endpoint.java index d4c76ea..075d699 100644 --- a/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Endpoint.java +++ b/components/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/firehose/KinesisFirehose2Endpoint.java @@ -28,11 +28,14 @@ import org.apache.camel.support.DefaultEndpoint; 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.firehose.FirehoseClient; import software.amazon.awssdk.services.firehose.FirehoseClientBuilder; +import software.amazon.awssdk.utils.AttributeMap; /** * Produce data to AWS Kinesis Firehose streams using AWS SDK version 2.x. @@ -106,6 +109,16 @@ public class KinesisFirehose2Endpoint extends DefaultEndpoint { 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; }