Skip to content

Commit 91f4541

Browse files
committed
Merge branch '2.2.x' into 2.3.x
See gh-24052
2 parents 2ffb81f + 006d4bc commit 91f4541

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ private void configureSslTrustStore(AbstractHttp11JsseProtocol<?> protocol, Ssl
148148
throw new WebServerException("Could not load trust store: " + ex.getMessage(), ex);
149149
}
150150
}
151-
protocol.setTruststorePass(ssl.getTrustStorePassword());
151+
if (ssl.getTrustStorePassword() != null) {
152+
protocol.setTruststorePass(ssl.getTrustStorePassword());
153+
}
152154
if (ssl.getTrustStoreType() != null) {
153155
protocol.setTruststoreType(ssl.getTrustStoreType());
154156
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ void keyPasswordIsNotSetWhenNull() {
206206
assertThat(protocol.getKeyPass()).isEqualTo("password");
207207
}
208208

209+
@Test
210+
void trustStorePasswordIsNotSetWhenNull() {
211+
Http11NioProtocol protocol = (Http11NioProtocol) this.tomcat.getConnector().getProtocolHandler();
212+
protocol.setTruststorePass("password");
213+
Ssl ssl = new Ssl();
214+
ssl.setKeyStore("src/test/resources/test.jks");
215+
ssl.setTrustStore("src/test/resources/test.jks");
216+
new SslConnectorCustomizer(ssl, null).customize(this.tomcat.getConnector());
217+
assertThat(protocol.getTruststorePass()).isEqualTo("password");
218+
}
219+
209220
private KeyStore loadStore() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
210221
KeyStore keyStore = KeyStore.getInstance("JKS");
211222
Resource resource = new ClassPathResource("test.jks");

0 commit comments

Comments
 (0)