Search in sources :

Example 16 with SelfSignedCertificate

use of io.vertx.core.net.SelfSignedCertificate in project hono by eclipse.

the class TenantServiceBasedX509AuthenticationTest method createClientCertificate.

@BeforeAll
static void createClientCertificate() throws GeneralSecurityException, IOException {
    final SelfSignedCertificate ssc = SelfSignedCertificate.create("eclipse.org");
    final CertificateFactory factory = CertificateFactory.getInstance("X.509");
    cert = (X509Certificate) factory.generateCertificate(new FileInputStream(ssc.certificatePath()));
    certPath = new Certificate[] { cert };
}
Also used : SelfSignedCertificate(io.vertx.core.net.SelfSignedCertificate) CertificateFactory(java.security.cert.CertificateFactory) FileInputStream(java.io.FileInputStream) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 17 with SelfSignedCertificate

use of io.vertx.core.net.SelfSignedCertificate in project vertx-examples by vert-x3.

the class Server method start.

@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);
}
Also used : AbstractVerticle(io.vertx.core.AbstractVerticle) HttpServerOptions(io.vertx.core.http.HttpServerOptions) SelfSignedCertificate(io.vertx.core.net.SelfSignedCertificate) Runner(io.vertx.example.util.Runner) SelfSignedCertificate(io.vertx.core.net.SelfSignedCertificate) HttpServerOptions(io.vertx.core.http.HttpServerOptions)

Aggregations

SelfSignedCertificate (io.vertx.core.net.SelfSignedCertificate)17 VertxTestContext (io.vertx.junit5.VertxTestContext)10 Tenant (org.eclipse.hono.service.management.tenant.Tenant)10 Test (org.junit.jupiter.api.Test)10 Truth.assertThat (com.google.common.truth.Truth.assertThat)9 Future (io.vertx.core.Future)9 Promise (io.vertx.core.Promise)9 HttpURLConnection (java.net.HttpURLConnection)9 TimeUnit (java.util.concurrent.TimeUnit)9 IntegrationTestSupport (org.eclipse.hono.tests.IntegrationTestSupport)9 Tenants (org.eclipse.hono.tests.Tenants)9 RegistryManagementConstants (org.eclipse.hono.util.RegistryManagementConstants)9 JsonObject (io.vertx.core.json.JsonObject)8 Timeout (io.vertx.junit5.Timeout)8 VertxExtension (io.vertx.junit5.VertxExtension)8 UUID (java.util.UUID)8 Constants (org.eclipse.hono.util.Constants)8 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 GeneralSecurityException (java.security.GeneralSecurityException)7