Commit da6a8e86 authored by Madhura Bhave's avatar Madhura Bhave

Merge branch '2.0.x'

parents 60bf4ef4 877c4f70
...@@ -113,6 +113,7 @@ class SslConnectorCustomizer implements TomcatConnectorCustomizer { ...@@ -113,6 +113,7 @@ class SslConnectorCustomizer implements TomcatConnectorCustomizer {
new SslStoreProviderUrlStreamHandlerFactory(sslStoreProvider)); new SslStoreProviderUrlStreamHandlerFactory(sslStoreProvider));
try { try {
if (sslStoreProvider.getKeyStore() != null) { if (sslStoreProvider.getKeyStore() != null) {
protocol.setKeystorePass("");
protocol.setKeystoreFile(SslStoreProviderUrlStreamHandlerFactory.KEY_STORE_URL); protocol.setKeystoreFile(SslStoreProviderUrlStreamHandlerFactory.KEY_STORE_URL);
} }
if (sslStoreProvider.getTrustStore() != null) { if (sslStoreProvider.getTrustStore() != null) {
......
...@@ -24,6 +24,7 @@ import java.security.KeyStoreException; ...@@ -24,6 +24,7 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector; import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory; import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
...@@ -154,6 +155,21 @@ public class SslConnectorCustomizerTests { ...@@ -154,6 +155,21 @@ public class SslConnectorCustomizerTests {
assertThat(sslHostConfig.getCertificateKeystoreFile()).contains(sslHostConfigWithDefaults.getCertificateKeystoreFile()); assertThat(sslHostConfig.getCertificateKeystoreFile()).contains(sslHostConfigWithDefaults.getCertificateKeystoreFile());
} }
@Test
public void customizeWhenSslStoreProviderPresentShouldIgnorePasswordFromSsl() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyPassword("password");
ssl.setKeyStorePassword("secret");
SslStoreProvider sslStoreProvider = mock(SslStoreProvider.class);
given(sslStoreProvider.getTrustStore()).willReturn(loadStore());
given(sslStoreProvider.getKeyStore()).willReturn(loadStore());
SslConnectorCustomizer customizer = new SslConnectorCustomizer(ssl, sslStoreProvider);
Connector connector = this.tomcat.getConnector();
customizer.customize(connector);
this.tomcat.start();
assertThat(connector.getState()).isEqualTo(LifecycleState.STARTED);
}
private KeyStore loadStore() throws KeyStoreException, IOException, private KeyStore loadStore() throws KeyStoreException, IOException,
NoSuchAlgorithmException, CertificateException { NoSuchAlgorithmException, CertificateException {
KeyStore keyStore = KeyStore.getInstance("JKS"); KeyStore keyStore = KeyStore.getInstance("JKS");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment