From c0fcc3f51990f66ef1f63071a1affc731aad1c25 Mon Sep 17 00:00:00 2001 From: Adrien LAUER Date: Tue, 1 Jun 2021 09:40:28 +0200 Subject: [PATCH] Add config to control SSL per client/cluster --- CHANGELOG.md | 4 ++++ pom.xml | 2 +- src/main/java/org/seedstack/redis/RedisConfig.java | 10 ++++++++++ .../java/org/seedstack/redis/internal/RedisPlugin.java | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b03e129..861bb35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 2.1.2 (2021-05-19) + +* [new] New `ssl` configuration option to enable or disable SSL/TLS for each client/cluster (enabled by default). + # Version 2.1.1 (2021-05-19) * [fix] Initialization was completely skipped when only Jedis clusters were configured. diff --git a/pom.xml b/pom.xml index 6d697c8..3c6eb2c 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ org.seedstack.addons.redis redis - 2.1.1-SNAPSHOT + 2.1.2-SNAPSHOT 3.12.0 diff --git a/src/main/java/org/seedstack/redis/RedisConfig.java b/src/main/java/org/seedstack/redis/RedisConfig.java index da2cfef..87307e4 100644 --- a/src/main/java/org/seedstack/redis/RedisConfig.java +++ b/src/main/java/org/seedstack/redis/RedisConfig.java @@ -58,6 +58,7 @@ public static abstract class CommonConfig { private int socketTimeout = Protocol.DEFAULT_TIMEOUT; @Min(0) private int socketInfiniteTimeout = Protocol.DEFAULT_TIMEOUT; + private boolean ssl = true; public JedisPoolConfig getPoolConfig() { return poolConfig; @@ -92,6 +93,15 @@ public int getSocketInfiniteTimeout() { public void setSocketInfiniteTimeout(int socketInfiniteTimeout) { this.socketInfiniteTimeout = socketInfiniteTimeout; } + + public boolean isSsl() { + return ssl; + } + + public CommonConfig setSsl(boolean ssl) { + this.ssl = ssl; + return this; + } } public static class ClientConfig extends CommonConfig { diff --git a/src/main/java/org/seedstack/redis/internal/RedisPlugin.java b/src/main/java/org/seedstack/redis/internal/RedisPlugin.java index b77155c..dd9d121 100644 --- a/src/main/java/org/seedstack/redis/internal/RedisPlugin.java +++ b/src/main/java/org/seedstack/redis/internal/RedisPlugin.java @@ -124,7 +124,7 @@ public void stop() { private JedisPool createJedisPool(RedisConfig.ClientConfig clientConfig, SSLProvider sslProvider) { - if (sslProvider.sslContext().isPresent()) { + if (clientConfig.isSsl() && sslProvider.sslContext().isPresent()) { SSLContext sslContext = sslProvider.sslContext().get(); return new JedisPool( clientConfig.getPoolConfig(), @@ -150,7 +150,7 @@ private JedisCluster createJedisCluster(RedisConfig.ClusterConfig clusterConfig, SSLSocketFactory sslSocketFactory; SSLParameters sslParameters; boolean ssl; - if (sslProvider.sslContext().isPresent()) { + if (clusterConfig.isSsl() && sslProvider.sslContext().isPresent()) { SSLContext sslContext = sslProvider.sslContext().get(); sslSocketFactory = sslContext.getSocketFactory(); sslParameters = sslContext.getSupportedSSLParameters();