Search in sources :

Example 6 with SSLOption

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

the class HighwayClient method createTcpClientConfig.

private TcpClientConfig createTcpClientConfig() {
    TcpClientConfig tcpClientConfig = new TcpClientConfig();
    DynamicLongProperty prop = AbstractTransport.getRequestTimeoutProperty();
    prop.addCallback(new Runnable() {

        public void run() {
            tcpClientConfig.setRequestTimeoutMillis(prop.get());
        }
    });
    tcpClientConfig.setRequestTimeoutMillis(prop.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) DynamicLongProperty(com.netflix.config.DynamicLongProperty)

Example 7 with SSLOption

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

the class ConfigCenterClient method createHttpClientOptions.

private HttpClientOptions createHttpClientOptions() {
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    if (ConfigCenterConfig.INSTANCE.isProxyEnable()) {
        ProxyOptions proxy = new ProxyOptions().setHost(ConfigCenterConfig.INSTANCE.getProxyHost()).setPort(ConfigCenterConfig.INSTANCE.getProxyPort()).setUsername(ConfigCenterConfig.INSTANCE.getProxyUsername()).setPassword(ConfigCenterConfig.INSTANCE.getProxyPasswd());
        httpClientOptions.setProxyOptions(proxy);
    }
    httpClientOptions.setConnectTimeout(CONFIG_CENTER_CONFIG.getConnectionTimeout());
    if (this.memberDiscovery.getConfigServer().toLowerCase().startsWith("https")) {
        LOGGER.debug("config center client performs requests over TLS");
        SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, ConfigCenterConfig.INSTANCE.getConcurrentCompositeConfiguration());
        SSLOption sslOption;
        if (factory == null) {
            sslOption = SSLOption.buildFromYaml(SSL_KEY, ConfigCenterConfig.INSTANCE.getConcurrentCompositeConfiguration());
        } else {
            sslOption = factory.createSSLOption();
        }
        SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
        VertxTLSBuilder.buildHttpClientOptions(sslOption, sslCustom, httpClientOptions);
    }
    return httpClientOptions;
}
Also used : ProxyOptions(io.vertx.core.net.ProxyOptions) SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 8 with SSLOption

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

the class DefaultMonitorDataPublisher method createHttpClientOptions.

private HttpClientOptions createHttpClientOptions() {
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    if (MonitorConstant.isProxyEnable()) {
        ProxyOptions proxy = new ProxyOptions();
        proxy.setHost(MonitorConstant.getProxyHost());
        proxy.setPort(MonitorConstant.getProxyPort());
        proxy.setUsername(MonitorConstant.getProxyUsername());
        proxy.setPassword(MonitorConstant.getProxyPasswd());
        httpClientOptions.setProxyOptions(proxy);
    }
    httpClientOptions.setConnectTimeout(MonitorConstant.getConnectionTimeout());
    if (MonitorConstant.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 : ProxyOptions(io.vertx.core.net.ProxyOptions) SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 9 with SSLOption

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

the class TransportUtils method createSSLProperties.

public static SSLProperties createSSLProperties(boolean sslEnabled, Configuration configuration, String tag) {
    SSLProperties sslProperties = new SSLProperties();
    sslProperties.setEnabled(sslEnabled);
    if (!sslEnabled) {
        return sslProperties;
    }
    SSLOption option = new SSLOption();
    option.setEngine(getStringProperty(configuration, DEFAULT_OPTION.getEngine(), "ssl." + tag + ".engine", "ssl.engine"));
    option.setProtocols(getStringProperty(configuration, DEFAULT_OPTION.getProtocols(), "ssl." + tag + ".protocols", "ssl.protocols"));
    option.setCiphers(getStringProperty(configuration, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".ciphers", "ssl.ciphers"));
    option.setAuthPeer(getBooleanProperty(configuration, DEFAULT_OPTION.isAuthPeer(), "ssl." + tag + ".authPeer", "ssl.authPeer"));
    option.setCheckCNHost(getBooleanProperty(configuration, DEFAULT_OPTION.isCheckCNHost(), "ssl." + tag + ".checkCN.host", "ssl.checkCN.host"));
    option.setCheckCNWhite(getBooleanProperty(configuration, DEFAULT_OPTION.isCheckCNWhite(), "ssl." + tag + ".checkCN.white", "ssl.checkCN.white"));
    option.setCheckCNWhiteFile(getStringProperty(configuration, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".checkCN.white.file", "ssl.checkCN.white.file"));
    option.setAllowRenegociate(getBooleanProperty(configuration, DEFAULT_OPTION.isAllowRenegociate(), "ssl." + tag + ".allowRenegociate", "ssl.allowRenegociate"));
    option.setStorePath(getStringProperty(configuration, DEFAULT_OPTION.getStorePath(), "ssl." + tag + ".storePath", "ssl.storePath"));
    option.setClientAuth(getStringProperty(configuration, DEFAULT_OPTION.getClientAuth(), "ssl." + tag + ".clientAuth", "ssl.clientAuth"));
    option.setTrustStore(getStringProperty(configuration, DEFAULT_OPTION.getTrustStore(), "ssl." + tag + ".trustStore", "ssl.trustStore"));
    option.setTrustStoreType(getStringProperty(configuration, DEFAULT_OPTION.getTrustStoreType(), "ssl." + tag + ".trustStoreType", "ssl.trustStoreType"));
    option.setTrustStoreValue(getStringProperty(configuration, DEFAULT_OPTION.getTrustStoreValue(), "ssl." + tag + ".trustStoreValue", "ssl.trustStoreValue"));
    option.setKeyStore(getStringProperty(configuration, DEFAULT_OPTION.getKeyStore(), "ssl." + tag + ".keyStore", "ssl.keyStore"));
    option.setKeyStoreType(getStringProperty(configuration, DEFAULT_OPTION.getKeyStoreType(), "ssl." + tag + ".keyStoreType", "ssl.keyStoreType"));
    option.setKeyStoreValue(getStringProperty(configuration, DEFAULT_OPTION.getKeyStoreValue(), "ssl." + tag + ".keyStoreValue", "ssl.keyStoreValue"));
    option.setCrl(getStringProperty(configuration, DEFAULT_OPTION.getCrl(), "ssl." + tag + ".crl", "ssl.crl"));
    option.setSslCustomClass(getStringProperty(configuration, 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 10 with SSLOption

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

the class TransportUtils method createSSLProperties.

public static SSLProperties createSSLProperties(boolean sslEnabled, Configuration configuration, String tag) {
    SSLProperties sslProperties = new SSLProperties();
    sslProperties.setEnabled(sslEnabled);
    if (!sslEnabled) {
        return sslProperties;
    }
    SSLOption option = new SSLOption();
    option.setEngine(getStringProperty(configuration, DEFAULT_OPTION.getEngine(), "ssl." + tag + ".engine", "ssl.engine"));
    option.setProtocols(getStringProperty(configuration, DEFAULT_OPTION.getProtocols(), "ssl." + tag + ".protocols", "ssl.protocols"));
    option.setCiphers(getStringProperty(configuration, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".ciphers", "ssl.ciphers"));
    option.setAuthPeer(getBooleanProperty(configuration, DEFAULT_OPTION.isAuthPeer(), "ssl." + tag + ".authPeer", "ssl.authPeer"));
    option.setCheckCNHost(getBooleanProperty(configuration, DEFAULT_OPTION.isCheckCNHost(), "ssl." + tag + ".checkCN.host", "ssl.checkCN.host"));
    option.setCheckCNWhite(getBooleanProperty(configuration, DEFAULT_OPTION.isCheckCNWhite(), "ssl." + tag + ".checkCN.white", "ssl.checkCN.white"));
    option.setCheckCNWhiteFile(getStringProperty(configuration, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".checkCN.white.file", "ssl.checkCN.white.file"));
    option.setAllowRenegociate(getBooleanProperty(configuration, DEFAULT_OPTION.isAllowRenegociate(), "ssl." + tag + ".allowRenegociate", "ssl.allowRenegociate"));
    option.setStorePath(getStringProperty(configuration, DEFAULT_OPTION.getStorePath(), "ssl." + tag + ".storePath", "ssl.storePath"));
    option.setClientAuth(getStringProperty(configuration, DEFAULT_OPTION.getClientAuth(), "ssl." + tag + ".clientAuth", "ssl.clientAuth"));
    option.setTrustStore(getStringProperty(configuration, DEFAULT_OPTION.getTrustStore(), "ssl." + tag + ".trustStore", "ssl.trustStore"));
    option.setTrustStoreType(getStringProperty(configuration, DEFAULT_OPTION.getTrustStoreType(), "ssl." + tag + ".trustStoreType", "ssl.trustStoreType"));
    option.setTrustStoreValue(getStringProperty(configuration, DEFAULT_OPTION.getTrustStoreValue(), "ssl." + tag + ".trustStoreValue", "ssl.trustStoreValue"));
    option.setKeyStore(getStringProperty(configuration, DEFAULT_OPTION.getKeyStore(), "ssl." + tag + ".keyStore", "ssl.keyStore"));
    option.setKeyStoreType(getStringProperty(configuration, DEFAULT_OPTION.getKeyStoreType(), "ssl." + tag + ".keyStoreType", "ssl.keyStoreType"));
    option.setKeyStoreValue(getStringProperty(configuration, DEFAULT_OPTION.getKeyStoreValue(), "ssl." + tag + ".keyStoreValue", "ssl.keyStoreValue"));
    option.setCrl(getStringProperty(configuration, DEFAULT_OPTION.getCrl(), "ssl." + tag + ".crl", "ssl.crl"));
    option.setSslCustomClass(getStringProperty(configuration, 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)

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