Search in sources :

Example 71 with Ssl

use of cn.taketoday.framework.web.server.Ssl in project today-infrastructure by TAKETODAY.

the class SslBuilderCustomizerTests method getKeyManagersWhenSslIsEnabledWithNoKeyStoreThrowsWebServerException.

@Test
void getKeyManagersWhenSslIsEnabledWithNoKeyStoreThrowsWebServerException() throws Exception {
    Ssl ssl = new Ssl();
    SslBuilderCustomizer customizer = new SslBuilderCustomizer(8080, InetAddress.getLocalHost(), ssl, null);
    assertThatIllegalStateException().isThrownBy(() -> ReflectionTestUtils.invokeMethod(customizer, "getKeyManagers", ssl, null)).withCauseInstanceOf(WebServerException.class).withMessageContaining("Could not load key store 'null'");
}
Also used : WebServerException(cn.taketoday.framework.web.server.WebServerException) Ssl(cn.taketoday.framework.web.server.Ssl) Test(org.junit.jupiter.api.Test)

Example 72 with Ssl

use of cn.taketoday.framework.web.server.Ssl in project today-infrastructure by TAKETODAY.

the class UndertowWebServerFactoryDelegate method createBuilder.

Builder createBuilder(AbstractConfigurableWebServerFactory factory) {
    Ssl ssl = factory.getSsl();
    InetAddress address = factory.getAddress();
    int port = factory.getPort();
    Builder builder = Undertow.builder();
    if (this.bufferSize != null) {
        builder.setBufferSize(this.bufferSize);
    }
    if (this.ioThreads != null) {
        builder.setIoThreads(this.ioThreads);
    }
    if (this.workerThreads != null) {
        builder.setWorkerThreads(this.workerThreads);
    }
    if (this.directBuffers != null) {
        builder.setDirectBuffers(this.directBuffers);
    }
    Http2 http2 = factory.getHttp2();
    if (http2 != null) {
        builder.setServerOption(UndertowOptions.ENABLE_HTTP2, http2.isEnabled());
    }
    if (ssl != null && ssl.isEnabled()) {
        new SslBuilderCustomizer(factory.getPort(), address, ssl, factory.getOrCreateSslStoreProvider()).customize(builder);
    } else {
        builder.addHttpListener(port, (address != null) ? address.getHostAddress() : "0.0.0.0");
    }
    builder.setServerOption(UndertowOptions.SHUTDOWN_TIMEOUT, 0);
    for (UndertowBuilderCustomizer customizer : this.builderCustomizers) {
        customizer.customize(builder);
    }
    return builder;
}
Also used : Builder(io.undertow.Undertow.Builder) Http2(cn.taketoday.framework.web.server.Http2) Ssl(cn.taketoday.framework.web.server.Ssl) InetAddress(java.net.InetAddress)

Aggregations

Ssl (cn.taketoday.framework.web.server.Ssl)72 Test (org.junit.jupiter.api.Test)58 Connector (org.apache.catalina.connector.Connector)12 SSLHostConfig (org.apache.tomcat.util.net.SSLHostConfig)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 SslStoreProvider (cn.taketoday.framework.web.server.SslStoreProvider)8 NoSuchProviderException (java.security.NoSuchProviderException)8 ServletRegistrationBean (cn.taketoday.framework.web.servlet.ServletRegistrationBean)6 HttpComponentsClientHttpRequestFactory (cn.taketoday.http.client.HttpComponentsClientHttpRequestFactory)6 ReactorClientHttpConnector (cn.taketoday.http.client.reactive.ReactorClientHttpConnector)6 ExampleServlet (cn.taketoday.test.web.servlet.ExampleServlet)6 WebClient (cn.taketoday.web.reactive.function.client.WebClient)6 KeyStore (java.security.KeyStore)6 HttpClient (org.apache.http.client.HttpClient)6 SSLConnectionSocketFactory (org.apache.http.conn.ssl.SSLConnectionSocketFactory)6 SSLContextBuilder (org.apache.http.ssl.SSLContextBuilder)6 WebServerException (cn.taketoday.framework.web.server.WebServerException)4 InetAddress (java.net.InetAddress)4 TrustSelfSignedStrategy (org.apache.http.conn.ssl.TrustSelfSignedStrategy)4 SSLHostConfigCertificate (org.apache.tomcat.util.net.SSLHostConfigCertificate)4