Search in sources :

Example 11 with JdkSslContext

use of org.apache.flink.shaded.netty4.io.netty.handler.ssl.JdkSslContext in project ratpack by ratpack.

the class ServerConfigDataDeserializer method deserialize.

@Override
public ServerConfigData deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    ObjectCodec codec = jp.getCodec();
    ObjectNode serverNode = jp.readValueAsTree();
    ServerConfigData data = new ServerConfigData(baseDirSupplier.get(), address, port, development, publicAddress);
    if (serverNode.hasNonNull("port")) {
        data.setPort(parsePort(serverNode.get("port")));
    }
    if (serverNode.hasNonNull("address")) {
        data.setAddress(toValue(codec, serverNode.get("address"), InetAddress.class));
    }
    if (serverNode.hasNonNull("idleTimeout")) {
        data.setIdleTimeout(toValue(codec, serverNode.get("idleTimeout"), Duration.class));
    }
    if (serverNode.hasNonNull("development")) {
        data.setDevelopment(serverNode.get("development").asBoolean(false));
    }
    if (serverNode.hasNonNull("threads")) {
        data.setThreads(serverNode.get("threads").asInt(ServerConfig.DEFAULT_THREADS));
    }
    if (serverNode.hasNonNull("registerShutdownHook")) {
        data.setRegisterShutdownHook(serverNode.get("registerShutdownHook").asBoolean(true));
    }
    if (serverNode.hasNonNull("publicAddress")) {
        data.setPublicAddress(toValue(codec, serverNode.get("publicAddress"), URI.class));
    }
    if (serverNode.hasNonNull("maxContentLength")) {
        data.setMaxContentLength(serverNode.get("maxContentLength").asInt(ServerConfig.DEFAULT_MAX_CONTENT_LENGTH));
    }
    if (serverNode.hasNonNull("maxChunkSize")) {
        data.setMaxChunkSize(serverNode.get("maxChunkSize").asInt(ServerConfig.DEFAULT_MAX_CHUNK_SIZE));
    }
    if (serverNode.hasNonNull("maxInitialLineLength")) {
        data.setMaxInitialLineLength(serverNode.get("maxInitialLineLength").asInt(ServerConfig.DEFAULT_MAX_INITIAL_LINE_LENGTH));
    }
    if (serverNode.hasNonNull("maxHeaderSize")) {
        data.setMaxHeaderSize(serverNode.get("maxHeaderSize").asInt(ServerConfig.DEFAULT_MAX_HEADER_SIZE));
    }
    if (serverNode.hasNonNull("requireClientSslAuth")) {
        data.setRequireClientSslAuth(serverNode.get("requireClientSslAuth").asBoolean(false));
    }
    if (serverNode.hasNonNull("ssl")) {
        data.setSslContext(toValue(codec, serverNode.get("ssl"), SslContext.class));
    } else if (serverNode.hasNonNull("jdkSsl")) {
        SSLContext jdkSslContext = toValue(codec, serverNode.get("jdkSsl"), SSLContext.class);
        data.setSslContext(new JdkSslContext(jdkSslContext, false, data.isRequireClientSslAuth() ? ClientAuth.REQUIRE : ClientAuth.NONE));
    }
    if (serverNode.hasNonNull("baseDir")) {
        throw new IllegalStateException("baseDir value cannot be set via config, it must be set directly via ServerConfigBuilder.baseDir()");
    }
    if (serverNode.hasNonNull("connectTimeoutMillis")) {
        parseOptionalIntValue("connectTimeoutMillis", serverNode.get("connectTimeoutMillis")).ifPresent(data::setConnectTimeoutMillis);
    }
    if (serverNode.hasNonNull("maxMessagesPerRead")) {
        parseOptionalIntValue("maxMessagesPerRead", serverNode.get("maxMessagesPerRead")).ifPresent(data::setMaxMessagesPerRead);
    }
    if (serverNode.hasNonNull("receiveBufferSize")) {
        parseOptionalIntValue("receiveBufferSize", serverNode.get("receiveBufferSize")).ifPresent(data::setReceiveBufferSize);
    }
    if (serverNode.hasNonNull("writeSpinCount")) {
        parseOptionalIntValue("writeSpinCount", serverNode.get("writeSpinCount")).ifPresent(data::setWriteSpinCount);
    }
    if (serverNode.hasNonNull("connectQueueSize")) {
        parseOptionalIntValue("connectQueueSize", serverNode.get("connectQueueSize")).ifPresent(data::setConnectQueueSize);
    }
    return data;
}
Also used : ServerConfigData(ratpack.server.internal.ServerConfigData) JdkSslContext(io.netty.handler.ssl.JdkSslContext) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Duration(java.time.Duration) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec) SSLContext(javax.net.ssl.SSLContext) InetAddress(java.net.InetAddress) URI(java.net.URI) JdkSslContext(io.netty.handler.ssl.JdkSslContext) SslContext(io.netty.handler.ssl.SslContext)

Example 12 with JdkSslContext

use of org.apache.flink.shaded.netty4.io.netty.handler.ssl.JdkSslContext in project reactor-netty by reactor.

the class ClientOptions method groupAndChannel.

@SuppressWarnings("unchecked")
final void groupAndChannel(Bootstrap bootstrap) {
    LoopResources loops = Objects.requireNonNull(getLoopResources(), "loopResources");
    boolean useNative = this.protocolFamily == null && preferNative() && !(sslContext() instanceof JdkSslContext);
    EventLoopGroup elg = loops.onClient(useNative);
    if (this.poolResources != null && elg instanceof Supplier) {
        // don't colocate
        bootstrap.group(((Supplier<EventLoopGroup>) elg).get());
    } else {
        bootstrap.group(elg);
    }
    if (useDatagramChannel()) {
        if (useNative) {
            bootstrap.channel(loops.onDatagramChannel(elg));
        } else {
            bootstrap.channelFactory(() -> new NioDatagramChannel(protocolFamily));
        }
    } else {
        bootstrap.channel(loops.onChannel(elg));
    }
}
Also used : JdkSslContext(io.netty.handler.ssl.JdkSslContext) EventLoopGroup(io.netty.channel.EventLoopGroup) NioDatagramChannel(io.netty.channel.socket.nio.NioDatagramChannel) LoopResources(reactor.ipc.netty.resources.LoopResources) Supplier(java.util.function.Supplier)

Example 13 with JdkSslContext

use of org.apache.flink.shaded.netty4.io.netty.handler.ssl.JdkSslContext in project reactor-netty by reactor.

the class ServerOptions method groupAndChannel.

final void groupAndChannel(ServerBootstrap bootstrap) {
    LoopResources loops = Objects.requireNonNull(getLoopResources(), "loopResources");
    boolean useNative = preferNative() && !(sslContext() instanceof JdkSslContext);
    final EventLoopGroup selectorGroup = loops.onServerSelect(useNative);
    final EventLoopGroup elg = loops.onServer(useNative);
    bootstrap.group(selectorGroup, elg).channel(loops.onServerChannel(elg));
}
Also used : JdkSslContext(io.netty.handler.ssl.JdkSslContext) EventLoopGroup(io.netty.channel.EventLoopGroup) LoopResources(reactor.ipc.netty.resources.LoopResources)

Example 14 with JdkSslContext

use of org.apache.flink.shaded.netty4.io.netty.handler.ssl.JdkSslContext in project rest.li by linkedin.

the class Http2ClientPipelineInitializer method configureHttpsPipeline.

/**
 * Sets up HTTP/2 over TLS through ALPN (h2) pipeline
 */
@SuppressWarnings("deprecation")
private void configureHttpsPipeline(NioSocketChannel ctx, Http2Connection connection) throws Exception {
    JdkSslContext context = new JdkSslContext(_sslContext, IS_CLIENT, Arrays.asList(_sslParameters.getCipherSuites()), IdentityCipherSuiteFilter.INSTANCE, // until we dont have a shadowed version of Netty
    new ApplicationProtocolConfig(ApplicationProtocolConfig.Protocol.ALPN, ApplicationProtocolConfig.SelectorFailureBehavior.NO_ADVERTISE, ApplicationProtocolConfig.SelectedListenerFailureBehavior.ACCEPT, ApplicationProtocolNames.HTTP_2, ApplicationProtocolNames.HTTP_1_1), _sslParameters.getNeedClientAuth() ? ClientAuth.REQUIRE : ClientAuth.OPTIONAL);
    Http2StreamCodec http2Codec = new Http2StreamCodecBuilder().connection(connection).maxContentLength(_maxResponseSize).gracefulShutdownTimeoutMillis(_gracefulShutdownTimeout).build();
    Http2AlpnHandler alpnHandler = new Http2AlpnHandler(context, http2Codec, _enableSSLSessionResumption, _sslHandShakeTimeout);
    Http2SchemeHandler schemeHandler = new Http2SchemeHandler(HttpScheme.HTTPS.toString());
    Http2StreamResponseHandler responseHandler = new Http2StreamResponseHandler();
    ctx.pipeline().addLast(Http2AlpnHandler.PIPELINE_ALPN_HANDLER, alpnHandler);
    ctx.pipeline().addLast("schemeHandler", schemeHandler);
    ctx.pipeline().addLast("responseHandler", responseHandler);
}
Also used : JdkSslContext(io.netty.handler.ssl.JdkSslContext) ApplicationProtocolConfig(io.netty.handler.ssl.ApplicationProtocolConfig)

Example 15 with JdkSslContext

use of org.apache.flink.shaded.netty4.io.netty.handler.ssl.JdkSslContext in project flink by apache.

the class SSLUtils method createRestSSLContext.

/**
 * Creates an SSL context for clients against the external REST endpoint.
 */
@Nullable
@VisibleForTesting
public static SSLContext createRestSSLContext(Configuration config, boolean clientMode) throws Exception {
    ClientAuth clientAuth = SecurityOptions.isRestSSLAuthenticationEnabled(config) ? ClientAuth.REQUIRE : ClientAuth.NONE;
    JdkSslContext nettySSLContext = (JdkSslContext) createRestNettySSLContext(config, clientMode, clientAuth, JDK);
    if (nettySSLContext != null) {
        return nettySSLContext.context();
    } else {
        return null;
    }
}
Also used : JdkSslContext(org.apache.flink.shaded.netty4.io.netty.handler.ssl.JdkSslContext) ClientAuth(org.apache.flink.shaded.netty4.io.netty.handler.ssl.ClientAuth) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting) Nullable(javax.annotation.Nullable)

Aggregations

JdkSslContext (io.netty.handler.ssl.JdkSslContext)14 SslContext (io.netty.handler.ssl.SslContext)4 SSLContext (javax.net.ssl.SSLContext)4 OpenSslContext (io.netty.handler.ssl.OpenSslContext)3 Channel (io.netty.channel.Channel)2 EventLoopGroup (io.netty.channel.EventLoopGroup)2 SocketChannel (io.netty.channel.socket.SocketChannel)2 ApplicationProtocolConfig (io.netty.handler.ssl.ApplicationProtocolConfig)2 SslHandler (io.netty.handler.ssl.SslHandler)2 VertxException (io.vertx.core.VertxException)2 HttpClientOptions (io.vertx.core.http.HttpClientOptions)2 HttpServerOptions (io.vertx.core.http.HttpServerOptions)2 HttpVersion (io.vertx.core.http.HttpVersion)2 HttpServerImpl (io.vertx.core.http.impl.HttpServerImpl)2 VertxInternal (io.vertx.core.impl.VertxInternal)2 JdkSSLEngineOptions (io.vertx.core.net.JdkSSLEngineOptions)2 OpenSSLEngineOptions (io.vertx.core.net.OpenSSLEngineOptions)2 SSLEngineOptions (io.vertx.core.net.SSLEngineOptions)2 SSLHelper (io.vertx.core.net.impl.SSLHelper)2 List (java.util.List)2