use of cn.taketoday.framework.web.server.Ssl in project today-framework by TAKETODAY.
the class SslBuilderCustomizerTests method getKeyManagersWhenAliasIsNullShouldNotDecorate.
@Test
void getKeyManagersWhenAliasIsNullShouldNotDecorate() throws Exception {
Ssl ssl = new Ssl();
ssl.setKeyPassword("password");
ssl.setKeyStore("src/test/resources/test.jks");
SslBuilderCustomizer customizer = new SslBuilderCustomizer(8080, InetAddress.getLocalHost(), ssl, null);
KeyManager[] keyManagers = ReflectionTestUtils.invokeMethod(customizer, "getKeyManagers", ssl, null);
Class<?> name = Class.forName("cn.taketoday.framework.web.embedded.undertow.SslBuilderCustomizer$ConfigurableAliasKeyManager");
assertThat(keyManagers[0]).isNotInstanceOf(name);
}
use of cn.taketoday.framework.web.server.Ssl in project today-framework by TAKETODAY.
the class SslBuilderCustomizerTests method trustStoreProviderIsUsedWhenCreatingTrustStore.
@Test
void trustStoreProviderIsUsedWhenCreatingTrustStore() throws Exception {
Ssl ssl = new Ssl();
ssl.setTrustStorePassword("password");
ssl.setTrustStore("src/test/resources/test.jks");
ssl.setTrustStoreProvider("com.example.TrustStoreProvider");
SslBuilderCustomizer customizer = new SslBuilderCustomizer(8080, InetAddress.getLocalHost(), ssl, null);
assertThatIllegalStateException().isThrownBy(() -> ReflectionTestUtils.invokeMethod(customizer, "getTrustManagers", ssl, null)).withCauseInstanceOf(NoSuchProviderException.class).withMessageContaining("com.example.TrustStoreProvider");
}
use of cn.taketoday.framework.web.server.Ssl in project today-framework by TAKETODAY.
the class AbstractReactiveWebServerFactoryTests method sslWantsClientAuthenticationSucceedsWithClientCertificate.
@Test
void sslWantsClientAuthenticationSucceedsWithClientCertificate() throws Exception {
Ssl ssl = new Ssl();
ssl.setClientAuth(Ssl.ClientAuth.WANT);
ssl.setKeyStore("classpath:test.jks");
ssl.setKeyPassword("password");
ssl.setKeyStorePassword("secret");
ssl.setTrustStore("classpath:test.jks");
testClientAuthSuccess(ssl, buildTrustAllSslWithClientKeyConnector("test.jks", "password"));
}
use of cn.taketoday.framework.web.server.Ssl in project today-framework by TAKETODAY.
the class AbstractReactiveWebServerFactoryTests method sslWithPemCertificates.
@Test
void sslWithPemCertificates() throws Exception {
Ssl ssl = new Ssl();
ssl.setClientAuth(Ssl.ClientAuth.NEED);
ssl.setCertificate("classpath:test-cert.pem");
ssl.setCertificatePrivateKey("classpath:test-key.pem");
ssl.setTrustCertificate("classpath:test-cert.pem");
ssl.setKeyStorePassword("secret");
testClientAuthSuccess(ssl, buildTrustAllSslWithClientKeyConnector("test.p12", "secret"));
}
use of cn.taketoday.framework.web.server.Ssl in project today-framework by TAKETODAY.
the class AbstractReactiveWebServerFactoryTests method sslNeedsClientAuthenticationSucceedsWithClientCertificate.
@Test
void sslNeedsClientAuthenticationSucceedsWithClientCertificate() throws Exception {
Ssl ssl = new Ssl();
ssl.setClientAuth(Ssl.ClientAuth.NEED);
ssl.setKeyStore("classpath:test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
ssl.setTrustStore("classpath:test.jks");
testClientAuthSuccess(ssl, buildTrustAllSslWithClientKeyConnector("test.jks", "password"));
}
Aggregations