mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-20 06:29:16 +00:00
Treat empty SSL bundle as unset
Update the Cassandra, Redis, and MongoDB SSL configuration so that an empty `bundle` property is treated as unset rather than enabling SSL. See gh-50624 Signed-off-by: Lee JiWon <dlwldnjs1009@gmail.com>
This commit is contained in:
committed by
Stéphane Nicoll
parent
8288b8fc36
commit
39ed20b474
+2
-1
@@ -23,6 +23,7 @@ import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Configuration properties for Cassandra.
|
||||
@@ -236,7 +237,7 @@ public class CassandraProperties {
|
||||
private String bundle;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return (this.enabled != null) ? this.enabled : this.bundle != null;
|
||||
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Configuration properties for Redis.
|
||||
@@ -425,7 +426,7 @@ public class RedisProperties {
|
||||
private String bundle;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return (this.enabled != null) ? this.enabled : this.bundle != null;
|
||||
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import com.mongodb.ConnectionString;
|
||||
import org.bson.UuidRepresentation;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Configuration properties for Mongo.
|
||||
@@ -289,7 +290,7 @@ public class MongoProperties {
|
||||
private String bundle;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return (this.enabled != null) ? this.enabled : this.bundle != null;
|
||||
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
|
||||
+7
@@ -58,4 +58,11 @@ class CassandraPropertiesTests {
|
||||
assertThat(driverDefaults.get(TypedDriverOption.HEARTBEAT_TIMEOUT)).isEqualTo(Duration.ofSeconds(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sslIsNotEnabledWhenBundleIsEmpty() {
|
||||
CassandraProperties properties = new CassandraProperties();
|
||||
properties.getSsl().setBundle("");
|
||||
assertThat(properties.getSsl().isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -39,4 +39,11 @@ class RedisPropertiesTests {
|
||||
.isEqualTo(defaultClusterTopologyRefreshOptions.useDynamicRefreshSources());
|
||||
}
|
||||
|
||||
@Test
|
||||
void sslIsNotEnabledWhenBundleIsEmpty() {
|
||||
RedisProperties properties = new RedisProperties();
|
||||
properties.getSsl().setBundle("");
|
||||
assertThat(properties.getSsl().isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -37,6 +37,13 @@ class MongoPropertiesTests {
|
||||
assertThat(springBootDefault).isEqualTo(springDataDefault);
|
||||
}
|
||||
|
||||
@Test
|
||||
void sslIsNotEnabledWhenBundleIsEmpty() {
|
||||
MongoProperties properties = new MongoProperties();
|
||||
properties.getSsl().setBundle("");
|
||||
assertThat(properties.getSsl().isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
private UuidRepresentation springDataDefaultUuidRepresentation() {
|
||||
return new MongoConfigurationSupport() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user