Search in sources :

Example 6 with OpenSSLEngineOptions

use of io.vertx.core.net.OpenSSLEngineOptions in project vert.x by eclipse.

the class SSLHelperTest method testOpenSslServerSessionContext.

private void testOpenSslServerSessionContext(boolean testDefault) {
    HttpServerOptions httpServerOptions = new HttpServerOptions().setOpenSslEngineOptions(new OpenSSLEngineOptions());
    if (!testDefault) {
        httpServerOptions.setOpenSslEngineOptions(new OpenSSLEngineOptions().setSessionCacheEnabled(false));
    }
    SSLHelper defaultHelper = new SSLHelper(httpServerOptions, Cert.SERVER_PEM.get(), Trust.SERVER_PEM.get());
    SslContext ctx = defaultHelper.getContext((VertxInternal) vertx);
    assertTrue(ctx instanceof OpenSslServerContext);
    SSLSessionContext sslSessionContext = ctx.sessionContext();
    assertTrue(sslSessionContext instanceof OpenSslServerSessionContext);
    if (sslSessionContext instanceof OpenSslServerSessionContext) {
        assertEquals(testDefault, ((OpenSslServerSessionContext) sslSessionContext).isSessionCacheEnabled());
    }
}
Also used : SSLHelper(io.vertx.core.net.impl.SSLHelper) SSLSessionContext(javax.net.ssl.SSLSessionContext) OpenSslServerContext(io.netty.handler.ssl.OpenSslServerContext) HttpServerOptions(io.vertx.core.http.HttpServerOptions) OpenSslServerSessionContext(io.netty.handler.ssl.OpenSslServerSessionContext) OpenSSLEngineOptions(io.vertx.core.net.OpenSSLEngineOptions) SslContext(io.netty.handler.ssl.SslContext)

Example 7 with OpenSSLEngineOptions

use of io.vertx.core.net.OpenSSLEngineOptions in project vert.x by eclipse.

the class SSLHelperTest method testUseOpenSSLCiphersWhenNotSpecified.

@Test
public void testUseOpenSSLCiphersWhenNotSpecified() throws Exception {
    Set<String> expected = OpenSsl.availableCipherSuites();
    SSLHelper helper = new SSLHelper(new HttpClientOptions().setOpenSslEngineOptions(new OpenSSLEngineOptions()), Cert.CLIENT_PEM.get(), Trust.SERVER_PEM.get());
    SslContext ctx = helper.getContext((VertxInternal) vertx);
    assertEquals(expected, new HashSet<>(ctx.cipherSuites()));
}
Also used : SSLHelper(io.vertx.core.net.impl.SSLHelper) HttpClientOptions(io.vertx.core.http.HttpClientOptions) OpenSSLEngineOptions(io.vertx.core.net.OpenSSLEngineOptions) SslContext(io.netty.handler.ssl.SslContext) Test(org.junit.Test)

Example 8 with OpenSSLEngineOptions

use of io.vertx.core.net.OpenSSLEngineOptions in project vert.x by eclipse.

the class Http2Test method testServerOpenSSL.

@Test
public void testServerOpenSSL() throws Exception {
    HttpServerOptions opts = new HttpServerOptions().setPort(DEFAULT_HTTPS_PORT).setHost(DEFAULT_HTTPS_HOST).setUseAlpn(true).setSsl(true).addEnabledCipherSuite(// Non Diffie-helman -> debuggable in wireshark
    "TLS_RSA_WITH_AES_128_CBC_SHA").setPemKeyCertOptions(Cert.SERVER_PEM.get()).setSslEngineOptions(new OpenSSLEngineOptions());
    server.close();
    client.close();
    client = vertx.createHttpClient(createBaseClientOptions());
    server = vertx.createHttpServer(opts);
    server.requestHandler(req -> {
        req.response().end();
    });
    CountDownLatch latch = new CountDownLatch(1);
    System.out.println("starting");
    try {
        server.listen(onSuccess(v -> latch.countDown()));
    } catch (Throwable e) {
        e.printStackTrace();
    }
    System.out.println("listening");
    awaitLatch(latch);
    client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> {
        assertEquals(200, resp.statusCode());
        testComplete();
    }).exceptionHandler(this::fail).end();
    await();
}
Also used : Test(org.junit.Test) CompletableFuture(java.util.concurrent.CompletableFuture) Http2Settings(io.vertx.core.http.Http2Settings) Cert(io.vertx.test.core.tls.Cert) Context(io.vertx.core.Context) TimeUnit(java.util.concurrent.TimeUnit) HttpClientRequest(io.vertx.core.http.HttpClientRequest) CountDownLatch(java.util.concurrent.CountDownLatch) OpenSSLEngineOptions(io.vertx.core.net.OpenSSLEngineOptions) Buffer(io.vertx.core.buffer.Buffer) NetServer(io.vertx.core.net.NetServer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HttpServerResponse(io.vertx.core.http.HttpServerResponse) PemKeyCertOptions(io.vertx.core.net.PemKeyCertOptions) HttpServerOptions(io.vertx.core.http.HttpServerOptions) HttpClientOptions(io.vertx.core.http.HttpClientOptions) StreamResetException(io.vertx.core.http.StreamResetException) HttpServerOptions(io.vertx.core.http.HttpServerOptions) CountDownLatch(java.util.concurrent.CountDownLatch) OpenSSLEngineOptions(io.vertx.core.net.OpenSSLEngineOptions) Test(org.junit.Test)

Aggregations

OpenSSLEngineOptions (io.vertx.core.net.OpenSSLEngineOptions)8 Test (org.junit.Test)7 HttpClientOptions (io.vertx.core.http.HttpClientOptions)3 HttpServerOptions (io.vertx.core.http.HttpServerOptions)3 SslContext (io.netty.handler.ssl.SslContext)2 SSLHelper (io.vertx.core.net.impl.SSLHelper)2 Cert (io.vertx.test.core.tls.Cert)2 OpenSslServerContext (io.netty.handler.ssl.OpenSslServerContext)1 OpenSslServerSessionContext (io.netty.handler.ssl.OpenSslServerSessionContext)1 Context (io.vertx.core.Context)1 Buffer (io.vertx.core.buffer.Buffer)1 Http2Settings (io.vertx.core.http.Http2Settings)1 HttpClient (io.vertx.core.http.HttpClient)1 HttpClientRequest (io.vertx.core.http.HttpClientRequest)1 HttpServerResponse (io.vertx.core.http.HttpServerResponse)1 StreamResetException (io.vertx.core.http.StreamResetException)1 VertxInternal (io.vertx.core.impl.VertxInternal)1 JsonObject (io.vertx.core.json.JsonObject)1 NetServer (io.vertx.core.net.NetServer)1 PemKeyCertOptions (io.vertx.core.net.PemKeyCertOptions)1