Search in sources :

Example 1 with SSLOptionFactory

use of io.servicecomb.foundation.ssl.SSLOptionFactory 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 SSLOptionFactory

use of io.servicecomb.foundation.ssl.SSLOptionFactory 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 SSLOptionFactory

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

the class TcpServer method init.

public void init(Vertx vertx, String sslKey, AsyncResultCallback<InetSocketAddress> callback) {
    NetServer netServer;
    if (endpointObject.isSslEnabled()) {
        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());
        NetServerOptions serverOptions = new NetServerOptions();
        VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions);
        netServer = vertx.createNetServer(serverOptions);
    } else {
        netServer = vertx.createNetServer();
    }
    netServer.connectHandler(netSocket -> {
        TcpServerConnection connection = createTcpServerConnection();
        connection.init(netSocket);
    });
    InetSocketAddress socketAddress = endpointObject.getSocketAddress();
    netServer.listen(socketAddress.getPort(), socketAddress.getHostString(), ar -> {
        if (ar.succeeded()) {
            callback.success(socketAddress);
            return;
        }
        String msg = String.format("listen failed, address=%s", socketAddress.toString());
        callback.fail(new Exception(msg, ar.cause()));
    });
}
Also used : SSLOptionFactory(io.servicecomb.foundation.ssl.SSLOptionFactory) InetSocketAddress(java.net.InetSocketAddress) NetServerOptions(io.vertx.core.net.NetServerOptions) NetServer(io.vertx.core.net.NetServer) SSLOption(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom)

Example 4 with SSLOptionFactory

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

the class HighwayClient method createTcpClientConfig.

private TcpClientConfig createTcpClientConfig() {
    TcpClientConfig tcpClientConfig = new TcpClientConfig();
    tcpClientConfig.setRequestTimeoutMillis(AbstractTransport.getRequestTimeout());
    tcpClientConfig.setTcpLogin(this);
    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.buildClientOptionsBase(sslOption, sslCustom, tcpClientConfig);
    }
    return tcpClientConfig;
}
Also used : TcpClientConfig(io.servicecomb.foundation.vertx.client.tcp.TcpClientConfig) SSLOptionFactory(io.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom)

Example 5 with SSLOptionFactory

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

the class AbstractClientPool method buildSecureClientOptions.

protected void buildSecureClientOptions(HttpClientOptions httpClientOptions) {
    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);
}
Also used : SSLOptionFactory(io.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(io.servicecomb.foundation.ssl.SSLOption) SSLCustom(io.servicecomb.foundation.ssl.SSLCustom)

Aggregations

SSLCustom (io.servicecomb.foundation.ssl.SSLCustom)5 SSLOption (io.servicecomb.foundation.ssl.SSLOption)5 SSLOptionFactory (io.servicecomb.foundation.ssl.SSLOptionFactory)5 TcpClientConfig (io.servicecomb.foundation.vertx.client.tcp.TcpClientConfig)1 HttpClientOptions (io.vertx.core.http.HttpClientOptions)1 HttpServerOptions (io.vertx.core.http.HttpServerOptions)1 NetServer (io.vertx.core.net.NetServer)1 NetServerOptions (io.vertx.core.net.NetServerOptions)1 InetSocketAddress (java.net.InetSocketAddress)1