List of usage examples for io.vertx.core.http HttpServerOptions setClientAuth
@Override
public HttpServerOptions setClientAuth(ClientAuth clientAuth)
From source file:io.gravitee.am.gateway.vertx.VertxHttpServerFactory.java
License:Apache License
@Override public HttpServer getObject() throws Exception { HttpServerOptions options = new HttpServerOptions(); // Binding port options.setPort(httpServerConfiguration.getPort()); options.setHost(httpServerConfiguration.getHost()); // Netty pool buffers must be enabled by default options.setUsePooledBuffers(true);/* w w w .ja v a2s .co m*/ if (httpServerConfiguration.isSecured()) { options.setSsl(httpServerConfiguration.isSecured()); options.setUseAlpn(httpServerConfiguration.isAlpn()); if (httpServerConfiguration.isClientAuth()) { options.setClientAuth(ClientAuth.REQUIRED); } if (httpServerConfiguration.getTrustStorePath() != null) { options.setTrustStoreOptions(new JksOptions().setPath(httpServerConfiguration.getTrustStorePath()) .setPassword(httpServerConfiguration.getTrustStorePassword())); } if (httpServerConfiguration.getKeyStorePath() != null) { options.setKeyStoreOptions(new JksOptions().setPath(httpServerConfiguration.getKeyStorePath()) .setPassword(httpServerConfiguration.getKeyStorePassword())); } } // Customizable configuration options.setCompressionSupported(httpServerConfiguration.isCompressionSupported()); options.setIdleTimeout(httpServerConfiguration.getIdleTimeout()); options.setTcpKeepAlive(httpServerConfiguration.isTcpKeepAlive()); return vertx.createHttpServer(options); }
From source file:io.gravitee.gateway.standalone.vertx.VertxHttpServerFactory.java
License:Apache License
@Override public HttpServer getObject() throws Exception { HttpServerOptions options = new HttpServerOptions(); // Binding port options.setPort(httpServerConfiguration.getPort()); // Netty pool buffers must be enabled by default options.setUsePooledBuffers(true);//from w w w.j a v a2 s . c o m if (httpServerConfiguration.isSecured()) { options.setSsl(httpServerConfiguration.isSecured()); if (httpServerConfiguration.isClientAuth()) { options.setClientAuth(ClientAuth.REQUIRED); } options.setTrustStoreOptions(new JksOptions().setPath(httpServerConfiguration.getKeyStorePath()) .setPassword(httpServerConfiguration.getKeyStorePassword())); options.setKeyStoreOptions(new JksOptions().setPath(httpServerConfiguration.getTrustStorePath()) .setPassword(httpServerConfiguration.getKeyStorePassword())); } // Customizable configuration options.setCompressionSupported(httpServerConfiguration.isCompressionSupported()); options.setIdleTimeout(httpServerConfiguration.getIdleTimeout()); options.setTcpKeepAlive(httpServerConfiguration.isTcpKeepAlive()); return vertx.createHttpServer(options); }
From source file:io.nitor.api.backend.tls.SetupHttpServerOptions.java
License:Apache License
public static HttpServerOptions createHttpServerOptions(JsonObject config) { JsonObject tls = config.getJsonObject("tls"); HttpServerOptions httpOptions = new HttpServerOptions() // basic TCP/HTTP options .setReuseAddress(true).setCompressionSupported(false) // otherwise it automatically compresses based on response headers even if pre-compressed with e.g. proxy .setUsePooledBuffers(true).setCompressionLevel(2) .setIdleTimeout(config.getInteger("idleTimeout", (int) MINUTES.toSeconds(10))); if (!config.getBoolean("http2", true)) { httpOptions.setAlpnVersions(asList(HTTP_1_1)); }//from ww w .j av a 2s. c om if (tls != null) { httpOptions.setSsl(true) // server side certificate .setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath(tls.getString("serverKey")) .setCertPath(tls.getString("serverCert"))) // TLS tuning .addEnabledSecureTransportProtocol("TLSv1.2").addEnabledSecureTransportProtocol("TLSv1.3"); JsonObject clientAuth = config.getJsonObject("clientAuth"); if (httpOptions.isSsl() && clientAuth != null && clientAuth.getString("clientChain") != null) { // client side certificate httpOptions.setClientAuth(REQUEST) .setTrustOptions(new PemTrustOptions().addCertPath(clientAuth.getString("clientChain"))); } if (TRUE.equals(config.getBoolean("useNativeOpenSsl"))) { httpOptions.setUseAlpn(true).setSslEngineOptions(new OpenSSLEngineOptions()); cipherSuites.stream().map(SetupHttpServerOptions::javaCipherNameToOpenSSLName) .forEach(httpOptions::addEnabledCipherSuite); } else { httpOptions.setUseAlpn(DynamicAgent.enableJettyAlpn()) .setJdkSslEngineOptions(new JdkSSLEngineOptions()); cipherSuites.forEach(httpOptions::addEnabledCipherSuite); } } return httpOptions; }
From source file:org.wisdom.framework.vertx.Server.java
License:Apache License
private void bind(int p, Handler<AsyncResult<Void>> completion) { // Get port number. final int thePort = pickAPort(port); HttpServerOptions options = new HttpServerOptions(); if (ssl) {// w ww . j a v a 2s. c om options.setSsl(true); options.setTrustStoreOptions(SSLServerContext.getTrustStoreOption(accessor)); options.setKeyStoreOptions(SSLServerContext.getKeyStoreOption(accessor)); if (authentication) { options.setClientAuth(ClientAuth.REQUIRED); } } if (hasCompressionEnabled()) { options.setCompressionSupported(true); } if (configuration.getIntegerWithDefault("vertx.acceptBacklog", -1) != -1) { options.setAcceptBacklog(configuration.getInteger("vertx.acceptBacklog")); } if (configuration.getIntegerWithDefault("vertx.maxWebSocketFrameSize", -1) != -1) { options.setMaxWebsocketFrameSize(configuration.getInteger("vertx.maxWebSocketFrameSize")); } if (configuration.getStringArray("wisdom.websocket.subprotocols").length > 0) { options.setWebsocketSubProtocols(configuration.get("wisdom.websocket.subprotocols")); } if (configuration.getStringArray("vertx.websocket-subprotocols").length > 0) { options.setWebsocketSubProtocols(configuration.get("vertx.websocket-subprotocols")); } if (configuration.getIntegerWithDefault("vertx.receiveBufferSize", -1) != -1) { options.setReceiveBufferSize(configuration.getInteger("vertx.receiveBufferSize")); } if (configuration.getIntegerWithDefault("vertx.sendBufferSize", -1) != -1) { options.setSendBufferSize(configuration.getInteger("vertx.sendBufferSize")); } http = vertx.createHttpServer(options).requestHandler(new HttpHandler(vertx, accessor, this)) .websocketHandler(new WebSocketHandler(accessor, this)); http.listen(thePort, host, event -> { if (event.succeeded()) { logger.info("Wisdom is going to serve HTTP requests on port {}.", thePort); port = thePort; completion.handle(Future.succeededFuture()); } else if (port == 0) { logger.debug("Cannot bind on port {} (port already used probably)", thePort, event.cause()); bind(0, completion); } else { logger.error("Cannot bind on port {} (port already used probably)", thePort, event.cause()); completion.handle(Future.failedFuture("Cannot bind on port " + thePort)); } }); }