Merge branch '2.3.x'

See gh-24053
This commit is contained in:
Andy Wilkinson
2020-11-05 12:19:44 +00:00
2 changed files with 14 additions and 1 deletions

View File

@@ -148,7 +148,9 @@ class SslConnectorCustomizer implements TomcatConnectorCustomizer {
throw new WebServerException("Could not load trust store: " + ex.getMessage(), ex);
}
}
protocol.setTruststorePass(ssl.getTrustStorePassword());
if (ssl.getTrustStorePassword() != null) {
protocol.setTruststorePass(ssl.getTrustStorePassword());
}
if (ssl.getTrustStoreType() != null) {
protocol.setTruststoreType(ssl.getTrustStoreType());
}

View File

@@ -206,6 +206,17 @@ class SslConnectorCustomizerTests {
assertThat(protocol.getKeyPass()).isEqualTo("password");
}
@Test
void trustStorePasswordIsNotSetWhenNull() {
Http11NioProtocol protocol = (Http11NioProtocol) this.tomcat.getConnector().getProtocolHandler();
protocol.setTruststorePass("password");
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setTrustStore("src/test/resources/test.jks");
new SslConnectorCustomizer(ssl, null).customize(this.tomcat.getConnector());
assertThat(protocol.getTruststorePass()).isEqualTo("password");
}
private KeyStore loadStore() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
KeyStore keyStore = KeyStore.getInstance("JKS");
Resource resource = new ClassPathResource("test.jks");