Skip to content

Commit 108f284

Browse files
alonblsnicoll
authored andcommitted
Allow to disable SSL client authentication on the management port
When server and management are at different ports, and when server requires TLS client authentication, then there is no simple method to disable TLS client authentication for management port. This commit adds an additional "none" option to ssl.client-auth. Example: server.port=8080 server.ssl.enabled=true server.ssl.client-auth=need management.server.port=8081 management.server.ssl.enabled=true management.server.ssl.client-auth=none See gh-14985
1 parent 476fe6e commit 108f284

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@
303303
},
304304
{
305305
"name": "management.server.ssl.client-auth",
306-
"description": "Whether client authentication is wanted (\"want\") or needed (\"need\"). Requires a trust store."
306+
"description": "Whether client authentication is not wanted (\"none\"), wanted (\"want\") or needed (\"need\"). Requires a trust store."
307307
},
308308
{
309309
"name": "management.server.ssl.enabled",

spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
},
137137
{
138138
"name": "server.ssl.client-auth",
139-
"description": "Whether client authentication is wanted (\"want\") or needed (\"need\"). Requires a trust store."
139+
"description": "Whether client authentication is not wanted (\"none\"), wanted (\"want\") or needed (\"need\"). Requires a trust store."
140140
},
141141
{
142142
"name": "server.ssl.enabled",

spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ content into your application. Rather, pick only the properties that you need.
233233
server.servlet.session.timeout=30m # Session timeout. If a duration suffix is not specified, seconds will be used.
234234
server.servlet.session.tracking-modes= # Session tracking modes.
235235
server.ssl.ciphers= # Supported SSL ciphers.
236-
server.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store.
236+
server.ssl.client-auth= # Whether client authentication is not wanted ("none"), wanted ("want") or needed ("need"). Requires a trust store.
237237
server.ssl.enabled=true # Whether to enable SSL support.
238238
server.ssl.enabled-protocols= # Enabled SSL protocols.
239239
server.ssl.key-alias= # Alias that identifies the key in the key store.
@@ -1205,7 +1205,7 @@ content into your application. Rather, pick only the properties that you need.
12051205
management.server.port= # Management endpoint HTTP port (uses the same port as the application by default). Configure a different port to use management-specific SSL.
12061206
management.server.servlet.context-path= # Management endpoint context-path (for instance, `/management`). Requires a custom management.server.port.
12071207
management.server.ssl.ciphers= # Supported SSL ciphers.
1208-
management.server.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store.
1208+
management.server.ssl.client-auth= # Whether client authentication is not wanted ("none"), wanted ("want") or needed ("need"). Requires a trust store.
12091209
management.server.ssl.enabled=true # Whether to enable SSL support.
12101210
management.server.ssl.enabled-protocols= # Enabled SSL protocols.
12111211
management.server.ssl.key-alias= # Alias that identifies the key in the key store.

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/Ssl.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class Ssl {
2828

2929
private boolean enabled = true;
3030

31-
private ClientAuth clientAuth;
31+
private ClientAuth clientAuth = ClientAuth.NONE;
3232

3333
private String[] ciphers;
3434

@@ -69,16 +69,21 @@ public void setEnabled(boolean enabled) {
6969
}
7070

7171
/**
72-
* Return Whether client authentication is wanted ("want") or needed ("need").
73-
* Requires a trust store.
72+
* Return Whether client authentication is not wanted ("none"), wanted ("want") or
73+
* needed ("need"). Requires a trust store.
7474
* @return the {@link ClientAuth} to use
7575
*/
7676
public ClientAuth getClientAuth() {
7777
return this.clientAuth;
7878
}
7979

8080
public void setClientAuth(ClientAuth clientAuth) {
81-
this.clientAuth = clientAuth;
81+
if (clientAuth == null) {
82+
this.clientAuth = ClientAuth.NONE;
83+
}
84+
else {
85+
this.clientAuth = clientAuth;
86+
}
8287
}
8388

8489
/**
@@ -243,6 +248,11 @@ public void setProtocol(String protocol) {
243248
*/
244249
public enum ClientAuth {
245250

251+
/**
252+
* Client authentication is not wanted.
253+
*/
254+
NONE,
255+
246256
/**
247257
* Client authentication is wanted but not mandatory.
248258
*/

0 commit comments

Comments
 (0)