3131import org .apache .tomcat .util .net .SSLHostConfig ;
3232import org .junit .After ;
3333import org .junit .Before ;
34+ import org .junit .Rule ;
3435import org .junit .Test ;
3536
37+ import org .springframework .boot .testsupport .rule .OutputCapture ;
3638import org .springframework .boot .web .server .Ssl ;
3739import org .springframework .boot .web .server .SslStoreProvider ;
3840import org .springframework .core .io .ClassPathResource ;
@@ -54,6 +56,9 @@ public class SslConnectorCustomizerTests {
5456
5557 private Connector connector ;
5658
59+ @ Rule
60+ public OutputCapture output = new OutputCapture ();
61+
5762 @ Before
5863 public void setup () {
5964 this .tomcat = new Tomcat ();
@@ -64,6 +69,7 @@ public void setup() {
6469
6570 @ After
6671 public void stop () throws Exception {
72+ System .clearProperty ("javax.net.ssl.trustStorePassword" );
6773 ReflectionTestUtils .setField (TomcatURLStreamHandlerFactory .class , "instance" ,
6874 null );
6975 ReflectionTestUtils .setField (URL .class , "factory" , null );
@@ -167,10 +173,10 @@ public void customizeWhenSslStoreProviderProvidesOnlyTrustStoreShouldUseDefaultK
167173 @ Test
168174 public void customizeWhenSslStoreProviderPresentShouldIgnorePasswordFromSsl ()
169175 throws Exception {
176+ System .setProperty ("javax.net.ssl.trustStorePassword" , "trustStoreSecret" );
170177 Ssl ssl = new Ssl ();
171178 ssl .setKeyPassword ("password" );
172179 ssl .setKeyStorePassword ("secret" );
173- ssl .setTrustStorePassword ("trustStoreSecret" );
174180 SslStoreProvider sslStoreProvider = mock (SslStoreProvider .class );
175181 given (sslStoreProvider .getTrustStore ()).willReturn (loadStore ());
176182 given (sslStoreProvider .getKeyStore ()).willReturn (loadStore ());
@@ -180,6 +186,7 @@ public void customizeWhenSslStoreProviderPresentShouldIgnorePasswordFromSsl()
180186 customizer .customize (connector );
181187 this .tomcat .start ();
182188 assertThat (connector .getState ()).isEqualTo (LifecycleState .STARTED );
189+ assertThat (this .output .toString ()).doesNotContain ("Password verification failed" );
183190 }
184191
185192 private KeyStore loadStore () throws KeyStoreException , IOException ,
0 commit comments