Skip to content

Commit 39ed20b

Browse files
dlwldnjs1009snicoll
authored andcommitted
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>
1 parent 8288b8f commit 39ed20b

6 files changed

Lines changed: 27 additions & 3 deletions

File tree

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.springframework.boot.context.properties.ConfigurationProperties;
2525
import org.springframework.core.io.Resource;
26+
import org.springframework.util.StringUtils;
2627

2728
/**
2829
* Configuration properties for Cassandra.
@@ -236,7 +237,7 @@ public static class Ssl {
236237
private String bundle;
237238

238239
public boolean isEnabled() {
239-
return (this.enabled != null) ? this.enabled : this.bundle != null;
240+
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
240241
}
241242

242243
public void setEnabled(boolean enabled) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.List;
2121

2222
import org.springframework.boot.context.properties.ConfigurationProperties;
23+
import org.springframework.util.StringUtils;
2324

2425
/**
2526
* Configuration properties for Redis.
@@ -425,7 +426,7 @@ public static class Ssl {
425426
private String bundle;
426427

427428
public boolean isEnabled() {
428-
return (this.enabled != null) ? this.enabled : this.bundle != null;
429+
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
429430
}
430431

431432
public void setEnabled(boolean enabled) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.bson.UuidRepresentation;
2323

2424
import org.springframework.boot.context.properties.ConfigurationProperties;
25+
import org.springframework.util.StringUtils;
2526

2627
/**
2728
* Configuration properties for Mongo.
@@ -289,7 +290,7 @@ public static class Ssl {
289290
private String bundle;
290291

291292
public boolean isEnabled() {
292-
return (this.enabled != null) ? this.enabled : this.bundle != null;
293+
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
293294
}
294295

295296
public void setEnabled(boolean enabled) {

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraPropertiesTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,11 @@ void defaultValuesInManualMetadataAreConsistent() {
5858
assertThat(driverDefaults.get(TypedDriverOption.HEARTBEAT_TIMEOUT)).isEqualTo(Duration.ofSeconds(5));
5959
}
6060

61+
@Test
62+
void sslIsNotEnabledWhenBundleIsEmpty() {
63+
CassandraProperties properties = new CassandraProperties();
64+
properties.getSsl().setBundle("");
65+
assertThat(properties.getSsl().isEnabled()).isFalse();
66+
}
67+
6168
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisPropertiesTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,11 @@ void lettuceDefaultsAreConsistent() {
3939
.isEqualTo(defaultClusterTopologyRefreshOptions.useDynamicRefreshSources());
4040
}
4141

42+
@Test
43+
void sslIsNotEnabledWhenBundleIsEmpty() {
44+
RedisProperties properties = new RedisProperties();
45+
properties.getSsl().setBundle("");
46+
assertThat(properties.getSsl().isEnabled()).isFalse();
47+
}
48+
4249
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoPropertiesTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ void defaultUuidRepresentationIsAlignedWithSpringData() {
3737
assertThat(springBootDefault).isEqualTo(springDataDefault);
3838
}
3939

40+
@Test
41+
void sslIsNotEnabledWhenBundleIsEmpty() {
42+
MongoProperties properties = new MongoProperties();
43+
properties.getSsl().setBundle("");
44+
assertThat(properties.getSsl().isEnabled()).isFalse();
45+
}
46+
4047
private UuidRepresentation springDataDefaultUuidRepresentation() {
4148
return new MongoConfigurationSupport() {
4249

0 commit comments

Comments
 (0)