@Override public void start() throws Exception { SelfSignedCertificate certificate = SelfSignedCertificate.create(); HttpServerOptions serverOptions = new HttpServerOptions() .setSsl(true) .setKeyCertOptions(certificate.keyCertOptions()); vertx.createHttpServer(serverOptions).requestHandler(req -> { System.out.println("Got request " + req.uri()); for (String name : req.headers().names()) { System.out.println(name + ": " + req.headers().get(name)); } req.handler(data -> System.out.println("Got data " + data.toString("ISO-8859-1"))); req.endHandler(v -> { // Now send back a response req.response().setChunked(true); for (int i = 0; i < 10; i++) { req.response().write("server-data-chunk-" + i); } req.response().end(); }); }).listen(8282); }
CountDownLatch latch = new CountDownLatch(2); SelfSignedCertificate certificate = SelfSignedCertificate.create(); .setKeyCertOptions(certificate.keyCertOptions()) .setTrustOptions(certificate.trustOptions()); .setKeyCertOptions(certificate.keyCertOptions()) .setTrustOptions(certificate.trustOptions());
/** * Provides the {@link io.vertx.core.net.KeyCertOptions} RSA private key file in PEM format corresponding to the {@link io.vertx.rxjava.core.net.SelfSignedCertificate#privateKeyPath} * @return a {@link io.vertx.core.net.PemKeyCertOptions} based on the generated certificate. */ public PemKeyCertOptions keyCertOptions() { PemKeyCertOptions ret = delegate.keyCertOptions(); return ret; }
/** * Create a new <code>SelfSignedCertificate</code> instance. * @return a new instance. */ public static io.vertx.rxjava.core.net.SelfSignedCertificate create() { io.vertx.rxjava.core.net.SelfSignedCertificate ret = io.vertx.rxjava.core.net.SelfSignedCertificate.newInstance(io.vertx.core.net.SelfSignedCertificate.create()); return ret; }
/** * Provides the {@link io.vertx.core.net.TrustOptions} X.509 certificate file in PEM format corresponding to the {@link io.vertx.rxjava.core.net.SelfSignedCertificate#certificatePath} * @return a {@link io.vertx.core.net.PemTrustOptions} based on the generated certificate. */ public PemTrustOptions trustOptions() { PemTrustOptions ret = delegate.trustOptions(); return ret; }
/** * Filesystem path to the RSA private key file in PEM format * @return the absolute path to the private key. */ public String privateKeyPath() { String ret = delegate.privateKeyPath(); return ret; }
/** * Filesystem path to the X.509 certificate file in PEM format . * @return the absolute path to the certificate. */ public String certificatePath() { String ret = delegate.certificatePath(); return ret; }
/** * Delete the private key and certificate files. */ public void delete() { delegate.delete(); }
/** * Provides the {@link io.vertx.core.net.KeyCertOptions} RSA private key file in PEM format corresponding to the {@link io.vertx.rxjava.core.net.SelfSignedCertificate#privateKeyPath} * @return a {@link io.vertx.core.net.PemKeyCertOptions} based on the generated certificate. */ public PemKeyCertOptions keyCertOptions() { PemKeyCertOptions ret = delegate.keyCertOptions(); return ret; }
/** * Create a new <code>SelfSignedCertificate</code> instance with a fully-qualified domain name, * @param fqdn a fully qualified domain name. * @return a new instance. */ public static io.vertx.rxjava.core.net.SelfSignedCertificate create(String fqdn) { io.vertx.rxjava.core.net.SelfSignedCertificate ret = io.vertx.rxjava.core.net.SelfSignedCertificate.newInstance(io.vertx.core.net.SelfSignedCertificate.create(fqdn)); return ret; }
/** * Provides the {@link io.vertx.core.net.TrustOptions} X.509 certificate file in PEM format corresponding to the {@link io.vertx.rxjava.core.net.SelfSignedCertificate#certificatePath} * @return a {@link io.vertx.core.net.PemTrustOptions} based on the generated certificate. */ public PemTrustOptions trustOptions() { PemTrustOptions ret = delegate.trustOptions(); return ret; }
/** * Filesystem path to the RSA private key file in PEM format * @return the absolute path to the private key. */ public String privateKeyPath() { String ret = delegate.privateKeyPath(); return ret; }
/** * Filesystem path to the X.509 certificate file in PEM format . * @return the absolute path to the certificate. */ public String certificatePath() { String ret = delegate.certificatePath(); return ret; }
/** * Delete the private key and certificate files. */ public void delete() { delegate.delete(); }
@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(); }
CountDownLatch latch = new CountDownLatch(2); SelfSignedCertificate certificate = SelfSignedCertificate.create(); .setKeyCertOptions(certificate.keyCertOptions()) .setTrustOptions(certificate.trustOptions()); .setKeyCertOptions(certificate.keyCertOptions()) .setTrustOptions(certificate.trustOptions());
public static java.util.Map<String, Object> keyCertOptions(io.vertx.core.net.SelfSignedCertificate j_receiver) { return j_receiver.keyCertOptions() != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(j_receiver.keyCertOptions().toJson()) : null; } public static java.util.Map<String, Object> trustOptions(io.vertx.core.net.SelfSignedCertificate j_receiver) {
/** * Create a new <code>SelfSignedCertificate</code> instance. * @return a new instance. */ public static io.vertx.rxjava.core.net.SelfSignedCertificate create() { io.vertx.rxjava.core.net.SelfSignedCertificate ret = io.vertx.rxjava.core.net.SelfSignedCertificate.newInstance(io.vertx.core.net.SelfSignedCertificate.create()); return ret; }
public static java.util.Map<String, Object> trustOptions(io.vertx.core.net.SelfSignedCertificate j_receiver) { return j_receiver.trustOptions() != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(j_receiver.trustOptions().toJson()) : null; } }
@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(); }