@Override public WebSocketStream websocketStreamAbs(String url, MultiMap headers, WebsocketVersion version, String subProtocols) { URI uri; try { uri = new URI(url); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } String scheme = uri.getScheme(); if (!"ws".equals(scheme) && !"wss".equals(scheme)) { throw new IllegalArgumentException("Scheme: " + scheme); } boolean ssl = scheme.length() == 3; int port = uri.getPort(); if (port == -1) port = ssl ? 443 : 80; StringBuilder relativeUri = new StringBuilder(); if (uri.getRawPath() != null) { relativeUri.append(uri.getRawPath()); } if (uri.getRawQuery() != null) { relativeUri.append('?').append(uri.getRawQuery()); } if (uri.getRawFragment() != null) { relativeUri.append('#').append(uri.getRawFragment()); } RequestOptions options = new RequestOptions().setHost(uri.getHost()).setPort(port).setSsl(ssl).setURI(relativeUri.toString()); return websocketStream(options, headers, version, subProtocols); }
static RequestOptions getOptions(final Record record, final String normalizedUri) { final RequestOptions options = new RequestOptions(); options.setURI(normalizedUri); // Extract host / port final JsonObject location = record.getLocation(); options.setHost(location.getString("host")); options.setPort(location.getInteger("port")); LOGGER.info("[ ZERO ] Found remote host: {0}, port: {1}, uri: {2}", options.getHost(), String.valueOf(options.getPort()), options.getURI()); return options; } }
@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(); }
private String remoteUri() { final String uri = InOut.normalizeUri(this.context); final StringBuilder absoluteUri = new StringBuilder(); absoluteUri.append("http://").append(this.options.getHost()); absoluteUri.append(":").append(this.options.getPort()); absoluteUri.append(uri); final String remoteUri = absoluteUri.toString(); LOGGER.info("[ ZERO ] Multipart redirect uri: {0}", remoteUri); return remoteUri; }
static RequestOptions getOptions(final Record record, final String normalizedUri) { final RequestOptions options = new RequestOptions(); options.setURI(normalizedUri); // Extract host / port final JsonObject location = record.getLocation(); options.setHost(location.getString("host")); options.setPort(location.getInteger("port")); LOGGER.info("[ ZERO ] Found remote host: {0}, port: {1}, uri: {2}", options.getHost(), String.valueOf(options.getPort()), options.getURI()); return options; } }
private String remoteUri() { final String uri = InOut.normalizeUri(this.context); final StringBuilder absoluteUri = new StringBuilder(); absoluteUri.append("http://").append(this.options.getHost()); absoluteUri.append(":").append(this.options.getPort()); absoluteUri.append(uri); final String remoteUri = absoluteUri.toString(); LOGGER.info("[ ZERO ] Multipart redirect uri: {0}", remoteUri); return remoteUri; }
@Test // Client trusts all server certs public void testClearClientRequestOptionsSetClear() throws Exception { RequestOptions options = new RequestOptions().setHost(HttpTestBase.DEFAULT_HTTP_HOST).setURI("/").setPort(4043).setSsl(false); testTLS(Cert.NONE, Trust.NONE, Cert.SERVER_JKS, Trust.NONE, false, false, true, false, true, false, false, false, new String[0], client -> client.websocketStream(options)); }
@Test // Client trusts all server certs public void testSSLClientRequestOptionsSetClear() throws Exception { RequestOptions options = new RequestOptions().setHost(HttpTestBase.DEFAULT_HTTP_HOST).setURI("/").setPort(4043).setSsl(false); testTLS(Cert.NONE, Trust.NONE, Cert.SERVER_JKS, Trust.NONE, false, false, true, false, true, true, false, false, new String[0], client -> client.websocketStream(options)); }
@Test // Client trusts all server certs public void testClearClientRequestOptionsSetSSL() throws Exception { RequestOptions options = new RequestOptions().setHost(HttpTestBase.DEFAULT_HTTP_HOST).setURI("/").setPort(4043).setSsl(true); testTLS(Cert.NONE, Trust.NONE, Cert.SERVER_JKS, Trust.NONE, false, false, true, false, true, false, true, false, new String[0], client -> client.websocketStream(options)); }
@Test // Client trusts all server certs public void testSSLClientRequestOptionsSetSSL() throws Exception { RequestOptions options = new RequestOptions().setHost(HttpTestBase.DEFAULT_HTTP_HOST).setURI("/").setPort(4043).setSsl(true); testTLS(Cert.NONE, Trust.NONE, Cert.SERVER_JKS, Trust.NONE, false, false, true, false, true, true, true, false, new String[0], client -> client.websocketStream(options)); }
@Test // Client trusts all server certs public void testSSLClientRequestOptionsSetSSL() throws Exception { RequestOptions options = new RequestOptions().setHost(DEFAULT_HTTP_HOST).setPort(4043).setURI(DEFAULT_TEST_URI).setSsl(true); testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(true).requestOptions(options).pass(); }