From a43495038105724abff831e20842e5ad1798b002 Mon Sep 17 00:00:00 2001 From: Joe Johnson Date: Wed, 25 Jan 2023 10:57:26 -0600 Subject: [PATCH] Adding sslContext support to elasticache configuration. --- .../elasticache/ElastiCacheConfiguration.java | 8 ++++++++ .../elasticache/MemcacheClientFactoryImpl.java | 12 ++++++++++++ .../elasticache/MemcacheClientFactoryImplTest.java | 6 ++---- pom.xml | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/aws-elasticache-provider/src/main/java/com/google/code/ssm/providers/elasticache/ElastiCacheConfiguration.java b/aws-elasticache-provider/src/main/java/com/google/code/ssm/providers/elasticache/ElastiCacheConfiguration.java index df1eb03f..b03e17e0 100644 --- a/aws-elasticache-provider/src/main/java/com/google/code/ssm/providers/elasticache/ElastiCacheConfiguration.java +++ b/aws-elasticache-provider/src/main/java/com/google/code/ssm/providers/elasticache/ElastiCacheConfiguration.java @@ -19,6 +19,8 @@ import java.util.Collection; +import javax.net.ssl.SSLContext; + import lombok.Data; import lombok.EqualsAndHashCode; import net.spy.memcached.ConnectionFactoryBuilder; @@ -152,4 +154,10 @@ public class ElastiCacheConfiguration extends CacheConfiguration { */ private MetricCollector metricCollector; + private SSLContext sslContext; + + private String hostnameForTlsVerification; + + private Boolean skipTlsHostnameVerification; + } diff --git a/aws-elasticache-provider/src/main/java/com/google/code/ssm/providers/elasticache/MemcacheClientFactoryImpl.java b/aws-elasticache-provider/src/main/java/com/google/code/ssm/providers/elasticache/MemcacheClientFactoryImpl.java index bb76d289..cd30705b 100644 --- a/aws-elasticache-provider/src/main/java/com/google/code/ssm/providers/elasticache/MemcacheClientFactoryImpl.java +++ b/aws-elasticache-provider/src/main/java/com/google/code/ssm/providers/elasticache/MemcacheClientFactoryImpl.java @@ -158,6 +158,18 @@ private void setProviderSpecificSettings(final ConnectionFactoryBuilder builder, if (conf.getMetricCollector() != null) { builder.setMetricCollector(conf.getMetricCollector()); } + + if (conf.getSslContext() != null) { + builder.setSSLContext(conf.getSslContext()); + } + + if (conf.getHostnameForTlsVerification() != null) { + builder.setHostnameForTlsVerification(conf.getHostnameForTlsVerification()); + } + + if (conf.getSkipTlsHostnameVerification() != null) { + builder.setSkipTlsHostnameVerification(conf.getSkipTlsHostnameVerification()); + } } diff --git a/aws-elasticache-provider/src/test/java/com/google/code/ssm/providers/elasticache/MemcacheClientFactoryImplTest.java b/aws-elasticache-provider/src/test/java/com/google/code/ssm/providers/elasticache/MemcacheClientFactoryImplTest.java index 9a8a80ae..2263aa18 100644 --- a/aws-elasticache-provider/src/test/java/com/google/code/ssm/providers/elasticache/MemcacheClientFactoryImplTest.java +++ b/aws-elasticache-provider/src/test/java/com/google/code/ssm/providers/elasticache/MemcacheClientFactoryImplTest.java @@ -23,15 +23,13 @@ import java.util.Collections; import java.util.List; -import net.spy.memcached.FailureMode; - import org.junit.Before; import org.junit.Test; import com.google.code.ssm.providers.CacheClient; import com.google.code.ssm.providers.CacheConfiguration; -import com.google.code.ssm.providers.elasticache.MemcacheClientFactoryImpl; -import com.google.code.ssm.providers.elasticache.ElastiCacheConfiguration; + +import net.spy.memcached.FailureMode; /** * diff --git a/pom.xml b/pom.xml index 3874fd75..b9dc04e2 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,7 @@ 2.9.9 2.12.3 2.4.6 - 1.1.1 + 1.2.0 1.6.4 1.3.4 1.16.18