|
|
@ -31,8 +31,10 @@ import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
|
|
|
|
import org.apache.tomcat.util.net.SSLHostConfig;
|
|
|
|
import org.apache.tomcat.util.net.SSLHostConfig;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Before;
|
|
|
|
|
|
|
|
import org.junit.Rule;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.testsupport.rule.OutputCapture;
|
|
|
|
import org.springframework.boot.web.server.Ssl;
|
|
|
|
import org.springframework.boot.web.server.Ssl;
|
|
|
|
import org.springframework.boot.web.server.SslStoreProvider;
|
|
|
|
import org.springframework.boot.web.server.SslStoreProvider;
|
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
@ -54,6 +56,9 @@ public class SslConnectorCustomizerTests {
|
|
|
|
|
|
|
|
|
|
|
|
private Connector connector;
|
|
|
|
private Connector connector;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Rule
|
|
|
|
|
|
|
|
public OutputCapture output = new OutputCapture();
|
|
|
|
|
|
|
|
|
|
|
|
@Before
|
|
|
|
@Before
|
|
|
|
public void setup() {
|
|
|
|
public void setup() {
|
|
|
|
this.tomcat = new Tomcat();
|
|
|
|
this.tomcat = new Tomcat();
|
|
|
@ -64,6 +69,7 @@ public class SslConnectorCustomizerTests {
|
|
|
|
|
|
|
|
|
|
|
|
@After
|
|
|
|
@After
|
|
|
|
public void stop() throws Exception {
|
|
|
|
public void stop() throws Exception {
|
|
|
|
|
|
|
|
System.clearProperty("javax.net.ssl.trustStorePassword");
|
|
|
|
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
|
|
|
|
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
|
|
|
|
null);
|
|
|
|
null);
|
|
|
|
ReflectionTestUtils.setField(URL.class, "factory", null);
|
|
|
|
ReflectionTestUtils.setField(URL.class, "factory", null);
|
|
|
@ -167,6 +173,7 @@ public class SslConnectorCustomizerTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void customizeWhenSslStoreProviderPresentShouldIgnorePasswordFromSsl()
|
|
|
|
public void customizeWhenSslStoreProviderPresentShouldIgnorePasswordFromSsl()
|
|
|
|
throws Exception {
|
|
|
|
throws Exception {
|
|
|
|
|
|
|
|
System.setProperty("javax.net.ssl.trustStorePassword", "trustStoreSecret");
|
|
|
|
Ssl ssl = new Ssl();
|
|
|
|
Ssl ssl = new Ssl();
|
|
|
|
ssl.setKeyPassword("password");
|
|
|
|
ssl.setKeyPassword("password");
|
|
|
|
ssl.setKeyStorePassword("secret");
|
|
|
|
ssl.setKeyStorePassword("secret");
|
|
|
@ -179,6 +186,7 @@ public class SslConnectorCustomizerTests {
|
|
|
|
customizer.customize(connector);
|
|
|
|
customizer.customize(connector);
|
|
|
|
this.tomcat.start();
|
|
|
|
this.tomcat.start();
|
|
|
|
assertThat(connector.getState()).isEqualTo(LifecycleState.STARTED);
|
|
|
|
assertThat(connector.getState()).isEqualTo(LifecycleState.STARTED);
|
|
|
|
|
|
|
|
assertThat(this.output.toString()).doesNotContain("Password verification failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private KeyStore loadStore() throws KeyStoreException, IOException,
|
|
|
|
private KeyStore loadStore() throws KeyStoreException, IOException,
|
|
|
|