Interface SslEngineFactory

    • Method Detail

      • newSslEngine

        SSLEngine newSslEngine​(AsyncHttpClientConfig config,
                               String peerHost,
                               int peerPort)
        Creates a new SSLEngine.
        Parameters:
        config - the client config
        peerHost - the peer hostname
        peerPort - the peer port
        Returns:
        new engine
      • newSslEngine

        default SSLEngine newSslEngine​(AsyncHttpClientConfig config,
                                       String peerHost,
                                       int peerPort,
                                       boolean http2Allowed)
        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 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

        default void init​(AsyncHttpClientConfig config)
                   throws SSLException
        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

        default void destroy()
        Perform any necessary cleanup.