Skip to content

Commit 4f7de1c

Browse files
committed
Fix SslOptions.isSpecified() logic
Prior to this commit `SslOptions.isSpecified()` only returned `true` if both ciphers and enabled protocols were set. If should have returned `true` if either were set. Fixes gh-43082
1 parent bebdf69 commit 4f7de1c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ssl/SslOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public interface SslOptions {
4545
* @return {@code true} if SSL options have been specified
4646
*/
4747
default boolean isSpecified() {
48-
return (getCiphers() != null) && (getEnabledProtocols() != null);
48+
return (getCiphers() != null) || (getEnabledProtocols() != null);
4949
}
5050

5151
/**

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/ssl/SslOptionsTests.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,4 +72,22 @@ void ofWithNullSetCreatesSslOptions() {
7272
assertThat(options.getEnabledProtocols()).isNull();
7373
}
7474

75+
@Test
76+
void isSpecifiedWhenHasCiphers() {
77+
SslOptions options = SslOptions.of(Set.of("a", "b", "c"), null);
78+
assertThat(options.isSpecified()).isTrue();
79+
}
80+
81+
@Test
82+
void isSpecifiedWhenHasEnabledProtocols() {
83+
SslOptions options = SslOptions.of(null, Set.of("d", "e", "f"));
84+
assertThat(options.isSpecified()).isTrue();
85+
}
86+
87+
@Test
88+
void isSpecifiedWhenHasNoCiphersOrEnabledProtocols() {
89+
SslOptions options = SslOptions.NONE;
90+
assertThat(options.isSpecified()).isFalse();
91+
}
92+
7593
}

0 commit comments

Comments
 (0)