Search in sources :

Example 26 with SSLOption

use of org.apache.servicecomb.foundation.ssl.SSLOption in project java-chassis by ServiceComb.

the class TestVertxTLSBuilder method testbuildClientOptionsBaseFileNull.

@Test
public void testbuildClientOptionsBaseFileNull() {
    SSLOption option = SSLOption.buildFromYaml("rest.consumer");
    option.setKeyStore(null);
    option.setTrustStore(null);
    option.setCrl(null);
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpClientOptions serverOptions = new HttpClientOptions();
    VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.isTrustAll(), true);
}
Also used : SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 27 with SSLOption

use of org.apache.servicecomb.foundation.ssl.SSLOption in project java-chassis by ServiceComb.

the class TestVertxTLSBuilder method testbuildHttpClientOptions.

@Test
public void testbuildHttpClientOptions() {
    SSLOption option = SSLOption.buildFromYaml("rest.consumer");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpClientOptions serverOptions = new HttpClientOptions();
    VertxTLSBuilder.buildHttpClientOptions(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.isTrustAll(), true);
}
Also used : SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 28 with SSLOption

use of org.apache.servicecomb.foundation.ssl.SSLOption in project java-chassis by ServiceComb.

the class VertxTLSBuilder method buildHttpClientOptions.

public static void buildHttpClientOptions(String sslKey, HttpClientOptions httpClientOptions) {
    SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(sslKey, null);
    SSLOption sslOption;
    if (factory == null) {
        sslOption = SSLOption.buildFromYaml(sslKey);
    } else {
        sslOption = factory.createSSLOption();
    }
    SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
    buildHttpClientOptions(sslOption, sslCustom, httpClientOptions);
}
Also used : SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom)

Example 29 with SSLOption

use of org.apache.servicecomb.foundation.ssl.SSLOption in project java-chassis by ServiceComb.

the class RestServerVerticle method createDefaultHttpServerOptions.

private HttpServerOptions createDefaultHttpServerOptions() {
    HttpServerOptions serverOptions = new HttpServerOptions();
    serverOptions.setIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds());
    serverOptions.setCompressionSupported(TransportConfig.getCompressed());
    serverOptions.setMaxHeaderSize(TransportConfig.getMaxHeaderSize());
    serverOptions.setMaxFormAttributeSize(TransportConfig.getMaxFormAttributeSize());
    serverOptions.setCompressionLevel(TransportConfig.getCompressionLevel());
    serverOptions.setMaxChunkSize(TransportConfig.getMaxChunkSize());
    serverOptions.setDecompressionSupported(TransportConfig.getDecompressionSupported());
    serverOptions.setDecoderInitialBufferSize(TransportConfig.getDecoderInitialBufferSize());
    serverOptions.setHttp2ConnectionWindowSize(TransportConfig.getHttp2ConnectionWindowSize());
    serverOptions.setMaxInitialLineLength(TransportConfig.getMaxInitialLineLength());
    if (endpointObject.isHttp2Enabled()) {
        serverOptions.setUseAlpn(TransportConfig.getUseAlpn()).setInitialSettings(new Http2Settings().setPushEnabled(TransportConfig.getPushEnabled()).setMaxConcurrentStreams(TransportConfig.getMaxConcurrentStreams()).setHeaderTableSize(TransportConfig.getHttp2HeaderTableSize()).setInitialWindowSize(TransportConfig.getInitialWindowSize()).setMaxFrameSize(TransportConfig.getMaxFrameSize()).setMaxHeaderListSize(TransportConfig.getMaxHeaderListSize()));
    }
    if (endpointObject.isSslEnabled()) {
        SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
        SSLOption sslOption;
        if (factory == null) {
            sslOption = SSLOption.buildFromYaml(SSL_KEY);
        } else {
            sslOption = factory.createSSLOption();
        }
        SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
        VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions);
    }
    return serverOptions;
}
Also used : SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) HttpServerOptions(io.vertx.core.http.HttpServerOptions) Http2Settings(io.vertx.core.http.Http2Settings) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom)

Aggregations

SSLOption (org.apache.servicecomb.foundation.ssl.SSLOption)29 SSLCustom (org.apache.servicecomb.foundation.ssl.SSLCustom)26 Test (org.junit.Test)16 HttpClientOptions (io.vertx.core.http.HttpClientOptions)14 SSLOptionFactory (org.apache.servicecomb.foundation.ssl.SSLOptionFactory)10 MockUp (mockit.MockUp)8 HttpServerOptions (io.vertx.core.http.HttpServerOptions)6 SSLProperties (org.apache.servicecomb.http.client.common.HttpConfiguration.SSLProperties)3 NetServer (io.vertx.core.net.NetServer)2 NetServerOptions (io.vertx.core.net.NetServerOptions)2 ProxyOptions (io.vertx.core.net.ProxyOptions)2 InetSocketAddress (java.net.InetSocketAddress)2 TcpClientConfig (org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig)2 DynamicLongProperty (com.netflix.config.DynamicLongProperty)1 Http2Settings (io.vertx.core.http.Http2Settings)1 DefaultTcpServerMetrics (org.apache.servicecomb.foundation.vertx.metrics.DefaultTcpServerMetrics)1 DefaultServerEndpointMetric (org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultServerEndpointMetric)1