Search in sources :

Example 1 with SSLOption

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

the class RestTransportClient method createHttpClientOptions.

private HttpClientOptions createHttpClientOptions() {
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    if (this.sslEnabled) {
        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.buildHttpClientOptions(sslOption, sslCustom, httpClientOptions);
    }
    return httpClientOptions;
}
Also used : SSLOptionFactory(io.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 2 with SSLOption

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

the class RestServerVerticle method createDefaultHttpServerOptions.

private HttpServerOptions createDefaultHttpServerOptions() {
    HttpServerOptions serverOptions = new HttpServerOptions();
    serverOptions.setAcceptBacklog(ACCEPT_BACKLOG);
    serverOptions.setSendBufferSize(SEND_BUFFER_SIZE);
    serverOptions.setReceiveBufferSize(RECEIVE_BUFFER_SIZE);
    serverOptions.setUsePooledBuffers(true);
    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(io.servicecomb.foundation.ssl.SSLOptionFactory) HttpServerOptions(io.vertx.core.http.HttpServerOptions) SSLOption(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom)

Example 3 with SSLOption

use of io.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(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 4 with SSLOption

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

the class TestVertxTLSBuilder method testbuildHttpServerOptionsRequest.

@Test
public void testbuildHttpServerOptionsRequest() {
    SSLOption option = SSLOption.buildFromYaml("rest.provider");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpServerOptions serverOptions = new HttpServerOptions();
    new MockUp<SSLOption>() {

        @Mock
        public boolean isAuthPeer() {
            return false;
        }
    };
    VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
Also used : HttpServerOptions(io.vertx.core.http.HttpServerOptions) MockUp(mockit.MockUp) SSLOption(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom) Test(org.junit.Test)

Example 5 with SSLOption

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

the class TestVertxTLSBuilder method testbuildHttpServerOptions.

@Test
public void testbuildHttpServerOptions() {
    SSLOption option = SSLOption.buildFromYaml("rest.provider");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpServerOptions serverOptions = new HttpServerOptions();
    VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
Also used : HttpServerOptions(io.vertx.core.http.HttpServerOptions) SSLOption(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom) Test(org.junit.Test)

Aggregations

SSLCustom (io.servicecomb.foundation.ssl.SSLCustom)13 SSLOption (io.servicecomb.foundation.ssl.SSLOption)13 Test (org.junit.Test)8 HttpClientOptions (io.vertx.core.http.HttpClientOptions)7 SSLOptionFactory (io.servicecomb.foundation.ssl.SSLOptionFactory)5 MockUp (mockit.MockUp)4 HttpServerOptions (io.vertx.core.http.HttpServerOptions)3 TcpClientConfig (io.servicecomb.foundation.vertx.client.tcp.TcpClientConfig)1 NetServer (io.vertx.core.net.NetServer)1 NetServerOptions (io.vertx.core.net.NetServerOptions)1 InetSocketAddress (java.net.InetSocketAddress)1