Class DefaultSslEngineFactory

    • Constructor Detail

      • DefaultSslEngineFactory

        public DefaultSslEngineFactory()
    • Method Detail

      • newSslEngine

        public SSLEngine newSslEngine​(AsyncHttpClientConfig config,
                                      String peerHost,
                                      int peerPort,
                                      boolean http2Allowed)
        Description copied from interface: SslEngineFactory
        Creates a new SSLEngine, optionally permitting HTTP/2 (ALPN h2) negotiation.

        WebSocket connections pass http2Allowed = false: AsyncHttpClient does not implement RFC 8441 (WebSocket over HTTP/2), so a WebSocket connection must not negotiate h2 — otherwise the handshake is written as a plain HTTP/2 request and corrupts the connection. The default implementation ignores the flag and delegates to SslEngineFactory.newSslEngine(AsyncHttpClientConfig, String, int) for backwards compatibility; DefaultSslEngineFactory overrides it to advertise only http/1.1 in ALPN when http2Allowed is false.

        Parameters:
        config - the client config
        peerHost - the peer hostname
        peerPort - the peer port
        http2Allowed - whether HTTP/2 (ALPN h2) may be negotiated on this connection
        Returns:
        new engine
      • init

        public void init​(AsyncHttpClientConfig config)
                  throws SSLException
        Description copied from interface: SslEngineFactory
        Perform any necessary one-time configuration. This will be called just once before newSslEngine is called for the first time.
        Parameters:
        config - the client config
        Throws:
        SSLException - if initialization fails. If an exception is thrown, the instance will not be used as client creation will fail.
      • destroy

        public void destroy()
        Description copied from interface: SslEngineFactory
        Perform any necessary cleanup.
      • configureSslContextBuilder

        protected io.netty.handler.ssl.SslContextBuilder configureSslContextBuilder​(io.netty.handler.ssl.SslContextBuilder builder)
        The last step of configuring the SslContextBuilder used to create an SslContext when no context is provided in the AsyncHttpClientConfig. This defaults to no-op and is intended to be overridden as needed.
        Parameters:
        builder - builder with normal configuration applied
        Returns:
        builder to be used to build context (can be the same object as the input)