@Override public void start() throws Exception { // Note! in real-life you wouldn't often set trust all to true as it could leave you open to man in the middle attacks. vertx.createHttpClient(new HttpClientOptions().setSsl(true).setTrustAll(true)).getNow(4443, "localhost", "/", resp -> { System.out.println("Got response " + resp.statusCode()); resp.bodyHandler(body -> System.out.println("Got data " + body.toString("ISO-8859-1"))); }); } }
@Override public void start() throws Exception { // Note! in real-life you wouldn't often set trust all to true as it could leave you open to man in the middle attacks. HttpClientOptions options = new HttpClientOptions(). setSsl(true). setUseAlpn(true). setProtocolVersion(HttpVersion.HTTP_2). setTrustAll(true); vertx.createHttpClient(options ).getNow(8443, "localhost", "/", resp -> { System.out.println("Got response " + resp.statusCode() + " with protocol " + resp.version()); resp.bodyHandler(body -> System.out.println("Got data " + body.toString("ISO-8859-1"))); }); } }
@Override public void start() throws Exception { // Note! in real-life you wouldn't often set trust all to true as it could leave you open to man in the middle attacks. HttpClientOptions options = new HttpClientOptions(). setSsl(true). setUseAlpn(true). setProtocolVersion(HttpVersion.HTTP_2). setTrustAll(true); HttpClient client = vertx.createHttpClient(options); HttpClientRequest request = client.get(8443, "localhost", "/", resp -> { System.out.println("Got response " + resp.statusCode() + " with protocol " + resp.version()); resp.bodyHandler(body -> System.out.println("Got data " + body.toString("ISO-8859-1"))); }); // Set handler for server side push request.pushHandler(pushedReq -> { System.out.println("Receiving pushed content"); pushedReq.handler(pushedResp -> { pushedResp.bodyHandler(body -> System.out.println("Got pushed data " + body.toString("ISO-8859-1"))); }); }); request.end(); } }
setUseAlpn(true). setProtocolVersion(HttpVersion.HTTP_2). setTrustAll(true);
@Override public void start() throws Exception { HttpClientRequest request = vertx.createHttpClient(new HttpClientOptions() .setSsl(true) .setTrustAll(true) .setVerifyHost(false) .setProxyOptions(new ProxyOptions() .setType(ProxyType.HTTP) .setHost("localhost") .setPort(8080))) .put(8282, "localhost", "/", resp -> { System.out.println("Got response " + resp.statusCode()); resp.bodyHandler(body -> System.out.println("Got data " + body.toString("ISO-8859-1"))); }); request.setChunked(true); for (int i = 0; i < 10; i++) { request.write("client-chunk-" + i); } request.end(); } }
@Test public void testWebsocketAbs() { SelfSignedCertificate certificate = SelfSignedCertificate.create(); HttpServerOptions serverOptions = new HttpServerOptions().setPort(HttpTestBase.DEFAULT_HTTPS_PORT) .setSsl(true) .setKeyCertOptions(certificate.keyCertOptions()); HttpClientOptions clientOptions = new HttpClientOptions() .setTrustAll(true) .setVerifyHost(false); client = vertx.createHttpClient(clientOptions); server = vertx.createHttpServer(serverOptions).requestHandler(request -> { if ("/test".equals(request.path())) { request.upgrade().close(); } else { request.response().end(); } }).listen(onSuccess(server -> { String url = "wss://" + clientOptions.getDefaultHost() + ":" + HttpTestBase.DEFAULT_HTTPS_PORT + "/test"; client.websocketAbs(url, null, null, null, ws -> { ws.closeHandler(v -> { testComplete(); }); }, null); })); await(); }
@Test public void testClearClientSslOptions() { SelfSignedCertificate certificate = SelfSignedCertificate.create(); HttpServerOptions serverOptions = new HttpServerOptions().setPort(HttpTestBase.DEFAULT_HTTPS_PORT) .setSsl(true) .setKeyCertOptions(certificate.keyCertOptions()); HttpClientOptions clientOptions = new HttpClientOptions() .setTrustAll(true) .setVerifyHost(false); client = vertx.createHttpClient(clientOptions); server = vertx.createHttpServer(serverOptions).websocketHandler(WebSocketBase::close).listen(onSuccess(server -> { RequestOptions requestOptions = new RequestOptions().setPort(HttpTestBase.DEFAULT_HTTPS_PORT).setSsl(true); client.websocket(requestOptions, ws -> { ws.closeHandler(v -> { testComplete(); }); }); })); await(); }
HttpClientOptions options = new HttpClientOptions(); options.setSsl(clientSsl); options.setTrustAll(clientTrustAll); if (clientUsesCrl) { options.addCrlPath("tls/root-ca/crl.pem");
options.setForceSni(clientForceSNI); if (clientTrustAll) { options.setTrustAll(true);
options.addEnabledCipherSuite(enabledCipher); options.setConnectTimeout(connectTimeout); options.setTrustAll(trustAll); options.addCrlPath(crlPath); options.addCrlValue(crlValue);
.setSsl(true) .setUseAlpn(useAlpn) .setTrustAll(true) .setProtocolVersion(version)); client.getNow(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", onSuccess(resp -> {
private void connect(final Runnable runnable) { final HttpClientOptions httpClientOptions = new HttpClientOptions(); final JksOptions jksOptions = new JksOptions(); jksOptions.setPath(trustStorePath).setPassword(trustStorePassword); httpClientOptions.setDefaultHost(host).setDefaultPort(port) .setConnectTimeout(timeOutInMilliseconds) .setMaxPoolSize(poolSize) .setKeepAlive(keepAlive) .setPipelining(pipeline) .setSoLinger(soLinger) .setTcpNoDelay(tcpNoDelay) .setTryUseCompression(tryUseCompression) .setSsl(ssl) .setTrustAll(trustAll) .setVerifyHost(verifyHost) .setMaxWebsocketFrameSize(maxWebSocketFrameSize) .setUsePooledBuffers(true); httpClient = vertx.createHttpClient(httpClientOptions); if (debug) logger.debug("HTTP CLIENT: connect:: \nhost {} \nport {}\n", host, port); closed.set(false); Sys.sleep(100); if (runnable != null) runnable.run(); }
@Test public void testWebsocketAbs() { SelfSignedCertificate certificate = SelfSignedCertificate.create(); HttpServerOptions serverOptions = new HttpServerOptions().setPort(HttpTestBase.DEFAULT_HTTPS_PORT) .setSsl(true) .setKeyCertOptions(certificate.keyCertOptions()); HttpClientOptions clientOptions = new HttpClientOptions() .setTrustAll(true) .setVerifyHost(false); client = vertx.createHttpClient(clientOptions); server = vertx.createHttpServer(serverOptions).requestHandler(request -> { if ("/test".equals(request.path())) { request.upgrade().close(); } else { request.response().end(); } }).listen(onSuccess(server -> { String url = "wss://" + clientOptions.getDefaultHost() + ":" + HttpTestBase.DEFAULT_HTTPS_PORT + "/test"; client.websocketAbs(url, null, null, null, ws -> { ws.closeHandler(v -> { testComplete(); }); }, null); })); await(); }
httpClientOptions .setVerifyHost(sslOptions.isHostnameVerifier()) .setTrustAll(sslOptions.isTrustAll());
@Test public void testClearClientSslOptions() { SelfSignedCertificate certificate = SelfSignedCertificate.create(); HttpServerOptions serverOptions = new HttpServerOptions().setPort(HttpTestBase.DEFAULT_HTTPS_PORT) .setSsl(true) .setKeyCertOptions(certificate.keyCertOptions()); HttpClientOptions clientOptions = new HttpClientOptions() .setTrustAll(true) .setVerifyHost(false); client = vertx.createHttpClient(clientOptions); server = vertx.createHttpServer(serverOptions).websocketHandler(WebSocketBase::close).listen(onSuccess(server -> { RequestOptions requestOptions = new RequestOptions().setPort(HttpTestBase.DEFAULT_HTTPS_PORT).setSsl(true); client.websocket(requestOptions, ws -> { ws.closeHandler(v -> { testComplete(); }); }); })); await(); }
assertEquals(options, options.setTrustAll(true)); assertTrue(options.isTrustAll());
HttpClientOptions options = new HttpClientOptions(); options.setSsl(clientSsl); options.setTrustAll(clientTrustAll); if (clientUsesCrl) { options.addCrlPath("tls/root-ca/crl.pem");
options.addEnabledCipherSuite(enabledCipher); options.setConnectTimeout(connectTimeout); options.setTrustAll(trustAll); options.addCrlPath(crlPath); options.addCrlValue(crlValue);
.setSsl(true) .setUseAlpn(useAlpn) .setTrustAll(true) .setProtocolVersion(version)); client.getNow(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", resp -> {
options.setForceSni(clientForceSNI); if (clientTrustAll) { options.setTrustAll(true);