Search in sources :

Example 16 with SSLOption

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

the class RBACBootStrapService method createSSLProperties.

private SSLProperties createSSLProperties(Environment environment, String tag) {
    SSLProperties sslProperties = new SSLProperties();
    SSLOption option = new SSLOption();
    option.setEngine(getStringProperty(environment, DEFAULT_OPTION.getEngine(), "ssl." + tag + ".engine", "ssl.engine"));
    option.setProtocols(getStringProperty(environment, DEFAULT_OPTION.getProtocols(), "ssl." + tag + ".protocols", "ssl.protocols"));
    option.setCiphers(getStringProperty(environment, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".ciphers", "ssl.ciphers"));
    option.setAuthPeer(getBooleanProperty(environment, DEFAULT_OPTION.isAuthPeer(), "ssl." + tag + ".authPeer", "ssl.authPeer"));
    option.setCheckCNHost(getBooleanProperty(environment, DEFAULT_OPTION.isCheckCNHost(), "ssl." + tag + ".checkCN.host", "ssl.checkCN.host"));
    option.setCheckCNWhite(getBooleanProperty(environment, DEFAULT_OPTION.isCheckCNWhite(), "ssl." + tag + ".checkCN.white", "ssl.checkCN.white"));
    option.setCheckCNWhiteFile(getStringProperty(environment, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".checkCN.white.file", "ssl.checkCN.white.file"));
    option.setAllowRenegociate(getBooleanProperty(environment, DEFAULT_OPTION.isAllowRenegociate(), "ssl." + tag + ".allowRenegociate", "ssl.allowRenegociate"));
    option.setStorePath(getStringProperty(environment, DEFAULT_OPTION.getStorePath(), "ssl." + tag + ".storePath", "ssl.storePath"));
    option.setClientAuth(getStringProperty(environment, DEFAULT_OPTION.getClientAuth(), "ssl." + tag + ".clientAuth", "ssl.clientAuth"));
    option.setTrustStore(getStringProperty(environment, DEFAULT_OPTION.getTrustStore(), "ssl." + tag + ".trustStore", "ssl.trustStore"));
    option.setTrustStoreType(getStringProperty(environment, DEFAULT_OPTION.getTrustStoreType(), "ssl." + tag + ".trustStoreType", "ssl.trustStoreType"));
    option.setTrustStoreValue(getStringProperty(environment, DEFAULT_OPTION.getTrustStoreValue(), "ssl." + tag + ".trustStoreValue", "ssl.trustStoreValue"));
    option.setKeyStore(getStringProperty(environment, DEFAULT_OPTION.getKeyStore(), "ssl." + tag + ".keyStore", "ssl.keyStore"));
    option.setKeyStoreType(getStringProperty(environment, DEFAULT_OPTION.getKeyStoreType(), "ssl." + tag + ".keyStoreType", "ssl.keyStoreType"));
    option.setKeyStoreValue(getStringProperty(environment, DEFAULT_OPTION.getKeyStoreValue(), "ssl." + tag + ".keyStoreValue", "ssl.keyStoreValue"));
    option.setCrl(getStringProperty(environment, DEFAULT_OPTION.getCrl(), "ssl." + tag + ".crl", "ssl.crl"));
    option.setSslCustomClass(getStringProperty(environment, null, "ssl." + tag + ".sslCustomClass", "ssl.sslCustomClass"));
    sslProperties.setSslOption(option);
    sslProperties.setSslCustom(SSLCustom.createSSLCustom(option.getSslCustomClass()));
    return sslProperties;
}
Also used : SSLProperties(org.apache.servicecomb.http.client.common.HttpConfiguration.SSLProperties) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption)

Example 17 with SSLOption

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

the class HighwayClient method createTcpClientConfig.

private TcpClientConfig createTcpClientConfig() {
    TcpClientConfig tcpClientConfig = new TcpClientConfig();
    // global request timeout to be login timeout
    tcpClientConfig.setMsLoginTimeout(DynamicPropertyFactory.getInstance().getLongProperty("servicecomb.request.timeout", TcpClientConfig.DEFAULT_LOGIN_TIMEOUT).get());
    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.buildClientOptionsBase(sslOption, sslCustom, tcpClientConfig);
    return tcpClientConfig;
}
Also used : TcpClientConfig(org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig) SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom)

Example 18 with SSLOption

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

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 19 with SSLOption

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

the class TestVertxTLSBuilder method testbuildClientOptionsBase.

@Test
public void testbuildClientOptionsBase() {
    SSLOption option = SSLOption.buildFromYaml("rest.consumer");
    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 20 with SSLOption

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

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)

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