Skip to content

Commit 781d7b0

Browse files
committed
Merge branch '3.2.x'
Closes gh-41010
2 parents b884932 + fe536bf commit 781d7b0

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/SslConnectorCustomizer.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.commons.logging.Log;
2323
import org.apache.coyote.ProtocolHandler;
2424
import org.apache.coyote.http11.AbstractHttp11JsseProtocol;
25-
import org.apache.coyote.http11.Http11NioProtocol;
2625
import org.apache.tomcat.util.net.SSLHostConfig;
2726
import org.apache.tomcat.util.net.SSLHostConfigCertificate;
2827
import org.apache.tomcat.util.net.SSLHostConfigCertificate.Type;
@@ -117,7 +116,7 @@ private void applySslBundle(AbstractHttp11JsseProtocol<?> protocol, SSLHostConfi
117116
String ciphers = StringUtils.arrayToCommaDelimitedString(options.getCiphers());
118117
sslHostConfig.setCiphers(ciphers);
119118
}
120-
configureSslStoreProvider(protocol, sslHostConfig, certificate, stores);
119+
configureSslStores(sslHostConfig, certificate, stores);
121120
configureEnabledProtocols(sslHostConfig, options);
122121
}
123122

@@ -132,10 +131,8 @@ private void configureSslClientAuth(SSLHostConfig config) {
132131
config.setCertificateVerification(ClientAuth.map(this.clientAuth, "none", "optional", "required"));
133132
}
134133

135-
private void configureSslStoreProvider(AbstractHttp11JsseProtocol<?> protocol, SSLHostConfig sslHostConfig,
136-
SSLHostConfigCertificate certificate, SslStoreBundle stores) {
137-
Assert.isInstanceOf(Http11NioProtocol.class, protocol,
138-
"SslStoreProvider can only be used with Http11NioProtocol");
134+
private void configureSslStores(SSLHostConfig sslHostConfig, SSLHostConfigCertificate certificate,
135+
SslStoreBundle stores) {
139136
try {
140137
if (stores.getKeyStore() != null) {
141138
certificate.setCertificateKeystore(stores.getKeyStore());

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.apache.catalina.valves.RemoteIpValve;
6161
import org.apache.coyote.ProtocolHandler;
6262
import org.apache.coyote.http11.AbstractHttp11Protocol;
63+
import org.apache.coyote.http11.Http11Nio2Protocol;
6364
import org.apache.hc.client5.http.HttpHostConnectException;
6465
import org.apache.hc.client5.http.classic.HttpClient;
6566
import org.apache.hc.client5.http.impl.classic.HttpClients;
@@ -681,6 +682,20 @@ void shouldUpdateSslWhenReloadingSslBundles() throws Exception {
681682
assertThat(verifier.getLastPrincipal()).isEqualTo("CN=2");
682683
}
683684

685+
@Test
686+
void sslWithHttp11Nio2Protocol() throws Exception {
687+
TomcatServletWebServerFactory factory = getFactory();
688+
addTestTxtFile(factory);
689+
factory.setProtocol(Http11Nio2Protocol.class.getName());
690+
factory.setSsl(getSsl(null, "password", "src/test/resources/test.jks"));
691+
this.webServer = factory.getWebServer();
692+
this.webServer.start();
693+
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
694+
new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
695+
HttpComponentsClientHttpRequestFactory requestFactory = createHttpComponentsRequestFactory(socketFactory);
696+
assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory)).isEqualTo("test");
697+
}
698+
684699
@Override
685700
protected JspServlet getJspServlet() throws ServletException {
686701
Tomcat tomcat = ((TomcatWebServer) this.webServer).getTomcat();

0 commit comments

Comments
 (0)