Skip to content

Commit

Permalink
Add config to control SSL per client/cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienlauer committed Jun 1, 2021
1 parent ea6a3d1 commit c0fcc3f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<groupId>org.seedstack.addons.redis</groupId>
<artifactId>redis</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>2.1.2-SNAPSHOT</version>

<properties>
<seed.version>3.12.0</seed.version>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/seedstack/redis/RedisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/seedstack/redis/internal/RedisPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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();
Expand Down

0 comments on commit c0fcc3f

Please sign in to comment.