Class AbstractClientTlsStrategy

java.lang.Object
org.apache.hc.client5.http.ssl.AbstractClientTlsStrategy
All Implemented Interfaces:
TlsSocketStrategy, org.apache.hc.core5.http.nio.ssl.TlsStrategy
Direct Known Subclasses:
DefaultClientTlsStrategy

@Contract(threading=STATELESS) abstract class AbstractClientTlsStrategy extends Object implements org.apache.hc.core5.http.nio.ssl.TlsStrategy, TlsSocketStrategy
  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
    • sslContext

      private final SSLContext sslContext
    • supportedProtocols

      private final String[] supportedProtocols
    • supportedCipherSuites

      private final String[] supportedCipherSuites
    • sslBufferManagement

      private final org.apache.hc.core5.reactor.ssl.SSLBufferMode sslBufferManagement
    • hostnameVerificationPolicy

      private final HostnameVerificationPolicy hostnameVerificationPolicy
    • hostnameVerifier

      private final HostnameVerifier hostnameVerifier
  • Constructor Details

  • Method Details

    • upgrade

      @Deprecated public boolean upgrade(org.apache.hc.core5.reactor.ssl.TransportSecurityLayer tlsSession, org.apache.hc.core5.http.HttpHost host, SocketAddress localAddress, SocketAddress remoteAddress, Object attachment, org.apache.hc.core5.util.Timeout handshakeTimeout)
      Specified by:
      upgrade in interface org.apache.hc.core5.http.nio.ssl.TlsStrategy
    • upgrade

      public void upgrade(org.apache.hc.core5.reactor.ssl.TransportSecurityLayer tlsSession, org.apache.hc.core5.net.NamedEndpoint endpoint, Object attachment, org.apache.hc.core5.util.Timeout handshakeTimeout, org.apache.hc.core5.concurrent.FutureCallback<org.apache.hc.core5.reactor.ssl.TransportSecurityLayer> callback)
      Specified by:
      upgrade in interface org.apache.hc.core5.http.nio.ssl.TlsStrategy
    • applyParameters

      abstract void applyParameters(SSLEngine sslEngine, SSLParameters sslParameters, String[] appProtocols)
    • createTlsDetails

      abstract org.apache.hc.core5.reactor.ssl.TlsDetails createTlsDetails(SSLEngine sslEngine)
    • initializeEngine

      protected void initializeEngine(SSLEngine sslEngine)
    • initializeSocket

      protected void initializeSocket(SSLSocket socket)
    • verifySession

      protected void verifySession(String hostname, SSLSession sslsession) throws SSLException
      Throws:
      SSLException
    • upgrade

      public SSLSocket upgrade(Socket socket, String target, int port, Object attachment, org.apache.hc.core5.http.protocol.HttpContext context) throws IOException
      Description copied from interface: TlsSocketStrategy
      Upgrades the given plain socket and executes the TLS handshake over it.
      Specified by:
      upgrade in interface TlsSocketStrategy
      Parameters:
      socket - the existing plain socket
      target - the name of the target host.
      port - the port to connect to on the target host.
      attachment - connect request attachment.
      context - the actual HTTP context.
      Returns:
      socket upgraded to TLS.
      Throws:
      IOException
    • executeHandshake

      private void executeHandshake(SSLSocket upgradedSocket, String target, Object attachment) throws IOException
      Throws:
      IOException
    • verifySession

      void verifySession(String hostname, SSLSession sslsession, HostnameVerifier hostnameVerifier) throws SSLException
      Throws:
      SSLException
    • toEscapedString

      @Internal String toEscapedString(X500Principal principal)
      Converts an X500Principal to a cleaned string by escaping control characters.

      This method processes the RFC2253 format of the X500Principal and escapes any ISO control characters to avoid issues in logging or other outputs. Control characters are replaced with their escaped hexadecimal representation.

      Note: For testing purposes, this method is package-private to allow access within the same package. This allows tests to verify the correct behavior of the escaping process.

      Parameters:
      principal - the X500Principal to escape
      Returns:
      the escaped string representation of the X500Principal