Skip to content

Commit 0a42082

Browse files
committed
Fail fast when trying to use SNI with reactive Jetty
Previously only a servlet-based Jetty server would fail fast when trying to use SNI with Jetty. A reactive Jetty server just ignored the configuration. This commit aligns the behavior of the two by making the reactive server fail fast as well. Closes gh-44316
1 parent 84998f9 commit 0a42082

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/web/embedded/jetty/JettyReactiveWebServerFactory.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 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.
@@ -249,6 +249,7 @@ private Handler applyWrapper(Handler handler, Handler.Wrapper wrapper) {
249249
}
250250

251251
private void customizeSsl(Server server, InetSocketAddress address) {
252+
Assert.state(getSsl().getServerNameBundles().isEmpty(), "Server name SSL bundles are not supported with Jetty");
252253
new SslServerCustomizer(getHttp2(), address, getSsl().getClientAuth(), getSslBundle()).customize(server);
253254
}
254255

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyReactiveWebServerFactoryTests.java

+18-1
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-2025 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.
@@ -20,6 +20,7 @@
2020
import java.net.InetAddress;
2121
import java.time.Duration;
2222
import java.util.Arrays;
23+
import java.util.List;
2324

2425
import org.awaitility.Awaitility;
2526
import org.eclipse.jetty.server.ConnectionLimit;
@@ -33,11 +34,14 @@
3334
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
3435
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactoryTests;
3536
import org.springframework.boot.web.server.Shutdown;
37+
import org.springframework.boot.web.server.Ssl;
38+
import org.springframework.boot.web.server.Ssl.ServerNameSslBundle;
3639
import org.springframework.http.server.reactive.HttpHandler;
3740
import org.springframework.web.reactive.function.client.WebClient;
3841

3942
import static org.assertj.core.api.Assertions.assertThat;
4043
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
44+
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
4145
import static org.mockito.ArgumentMatchers.any;
4246
import static org.mockito.Mockito.inOrder;
4347
import static org.mockito.Mockito.mock;
@@ -146,6 +150,19 @@ void shouldApplyMaxConnections() {
146150
assertThat(connectionLimit.getMaxConnections()).isOne();
147151
}
148152

153+
@Test
154+
void sslServerNameBundlesConfigurationThrowsException() {
155+
Ssl ssl = new Ssl();
156+
ssl.setBundle("test");
157+
List<ServerNameSslBundle> bundles = List.of(new ServerNameSslBundle("first", "test1"),
158+
new ServerNameSslBundle("second", "test2"));
159+
ssl.setServerNameBundles(bundles);
160+
JettyReactiveWebServerFactory factory = getFactory();
161+
factory.setSsl(ssl);
162+
assertThatIllegalStateException().isThrownBy(() -> this.webServer = factory.getWebServer(new EchoHandler()))
163+
.withMessageContaining("Server name SSL bundles are not supported with Jetty");
164+
}
165+
149166
@Override
150167
protected String startedLogMessage() {
151168
return ((JettyWebServer) this.webServer).getStartedLogMessage();

0 commit comments

Comments
 (0)