use of cn.taketoday.framework.web.server.Ssl in project today-infrastructure 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-infrastructure by TAKETODAY.
the class AbstractReactiveWebServerFactoryTests method sslWithValidAlias.
@Test
void sslWithValidAlias() {
String keyStore = "classpath:test.jks";
String keyPassword = "password";
AbstractReactiveWebServerFactory factory = getFactory();
Ssl ssl = new Ssl();
ssl.setKeyStore(keyStore);
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword(keyPassword);
ssl.setKeyAlias("test-alias");
factory.setSsl(ssl);
this.webServer = factory.getWebServer(new EchoHandler());
this.webServer.start();
ReactorClientHttpConnector connector = buildTrustAllSslConnector();
WebClient client = WebClient.builder().baseUrl("https://localhost:" + this.webServer.getPort()).clientConnector(connector).build();
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromValue("Hello World")).retrieve().bodyToMono(String.class);
StepVerifier.setDefaultTimeout(Duration.ofSeconds(30));
StepVerifier.create(result).expectNext("Hello World").verifyComplete();
}
use of cn.taketoday.framework.web.server.Ssl in project today-infrastructure by TAKETODAY.
the class ServletWebServerFactoryCustomizerTests method testCustomizeSsl.
@Test
void testCustomizeSsl() {
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
Ssl ssl = mock(Ssl.class);
this.properties.setSsl(ssl);
this.customizer.customize(factory);
then(factory).should().setSsl(ssl);
}
use of cn.taketoday.framework.web.server.Ssl in project today-infrastructure by TAKETODAY.
the class AbstractServletWebServerFactoryTests method getSsl.
private Ssl getSsl(String cert, String privateKey) {
Ssl ssl = new Ssl();
ssl.setClientAuth(ClientAuth.NEED);
ssl.setCertificate(cert);
ssl.setCertificatePrivateKey(privateKey);
ssl.setTrustCertificate(cert);
ssl.setKeyStorePassword("secret");
return ssl;
}
use of cn.taketoday.framework.web.server.Ssl in project today-infrastructure by TAKETODAY.
the class JettyServletWebServerFactoryTests method specificIPAddressWithSslIsNotReverseResolved.
@Test
void specificIPAddressWithSslIsNotReverseResolved() throws Exception {
JettyServletWebServerFactory factory = getFactory();
InetAddress localhost = InetAddress.getLocalHost();
factory.setAddress(InetAddress.getByAddress(localhost.getAddress()));
Ssl ssl = new Ssl();
ssl.setKeyStore("src/test/resources/test.jks");
ssl.setKeyStorePassword("secret");
ssl.setKeyPassword("password");
factory.setSsl(ssl);
this.webServer = factory.getWebServer();
this.webServer.start();
Connector connector = ((JettyWebServer) this.webServer).getServer().getConnectors()[0];
Assertions.assertThat(((ServerConnector) connector).getHost()).isEqualTo(localhost.getHostAddress());
}
Aggregations