Search in sources :

Example 11 with JksOptions

use of io.vertx.core.net.JksOptions in project java-chassis by ServiceComb.

the class GrpcTransport method createHttpClientOptions.

private HttpClientOptions createHttpClientOptions() {
    HttpClientOptions httpClientOptions = new HttpClientOptions();
    httpClientOptions.setProtocolVersion(HttpVersion.HTTP_2);
    httpClientOptions.setHttp2ClearTextUpgrade(false);
    String key = System.getProperty("store.key");
    if (key != null && !key.isEmpty()) {
        httpClientOptions.setUseAlpn(true);
        httpClientOptions.setSsl(true);
        httpClientOptions.setKeyStoreOptions(new JksOptions().setPath(System.getProperty("store.key")).setPassword(System.getProperty("store.pass")));
        httpClientOptions.setTrustAll(true);
        httpClientOptions.setVerifyHost(false);
    }
    return httpClientOptions;
}
Also used : JksOptions(io.vertx.core.net.JksOptions) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Example 12 with JksOptions

use of io.vertx.core.net.JksOptions in project java-chassis by ServiceComb.

the class GrpcVerticle method startListen.

protected void startListen(Future<Void> startFuture) {
    // 如果本地未配置grpc地址,则表示不必监听,只需要作为客户端使用即可
    if (StringUtils.isEmpty(this.endpoint)) {
        LOGGER.warn("grpc listen address is not configured, will not listen.");
        startFuture.complete();
        return;
    }
    Router mainRouter = Router.router(vertx);
    mainRouter.route().handler(new GrpcBodyHandler());
    new GrpcServer(mainRouter);
    HttpServerOptions serverOptions = new HttpServerOptions();
    serverOptions.setAcceptBacklog(ACCEPT_BACKLOG);
    serverOptions.setSendBufferSize(SEND_BUFFER_SIZE);
    serverOptions.setReceiveBufferSize(RECEIVE_BUFFER_SIZE);
    serverOptions.setUsePooledBuffers(true);
    String key = System.getProperty("store.key");
    if (key != null && !key.isEmpty()) {
        serverOptions.setUseAlpn(true);
        serverOptions.setSsl(true);
        serverOptions.setKeyStoreOptions(new JksOptions().setPath(System.getProperty("store.key")).setPassword(System.getProperty("store.pass")));
    }
    HttpServer server = vertx.createHttpServer(serverOptions).requestHandler(mainRouter::accept);
    IpPort ipPort = NetUtils.parseIpPortFromURI(this.endpoint);
    if (ipPort == null) {
        LOGGER.error("wrong grpc listen address {}", this.endpoint);
        return;
    }
    startListen(server, ipPort, startFuture);
}
Also used : JksOptions(io.vertx.core.net.JksOptions) HttpServerOptions(io.vertx.core.http.HttpServerOptions) HttpServer(io.vertx.core.http.HttpServer) Router(io.vertx.ext.web.Router) IpPort(io.servicecomb.foundation.common.net.IpPort)

Aggregations

JksOptions (io.vertx.core.net.JksOptions)12 Test (org.junit.Test)6 Buffer (io.vertx.core.buffer.Buffer)3 PfxOptions (io.vertx.core.net.PfxOptions)3 HttpServer (io.vertx.core.http.HttpServer)2 HttpServerOptions (io.vertx.core.http.HttpServerOptions)2 JsonObject (io.vertx.core.json.JsonObject)2 PemKeyCertOptions (io.vertx.core.net.PemKeyCertOptions)2 IpPort (io.servicecomb.foundation.common.net.IpPort)1 Vertx (io.vertx.core.Vertx)1 VertxOptions (io.vertx.core.VertxOptions)1 EventBus (io.vertx.core.eventbus.EventBus)1 EventBusOptions (io.vertx.core.eventbus.EventBusOptions)1 HttpClientOptions (io.vertx.core.http.HttpClientOptions)1 Router (io.vertx.ext.web.Router)1 Supplier (java.util.function.Supplier)1