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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations