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