Interface TlsSocketPlugin

All Known Implementing Classes:
DefaultTlsSocketPlugin

public interface TlsSocketPlugin
TLS Socket interface plugin
  • Method Details

    • type

      String type()
      plugin type.
      Returns:
      plugin type
    • getTrustManager

      TrustManager[] getTrustManager(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) throws SQLException
      Throws:
      SQLException
    • getKeyManager

      KeyManager[] getKeyManager(Configuration conf, ExceptionFactory exceptionFactory) throws SQLException
      Throws:
      SQLException
    • getSocketFactory

      default SSLSocketFactory getSocketFactory(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) throws SQLException
      Build an SSLSocketFactory for the given configuration.

      A fresh SSLContext is built on every call, so its (single-use) client SSL session cache is never shared between connections and TLS session resumption cannot occur across connections. The trust/key managers, the comparatively expensive part (loading key/trust stores), are what implementations are expected to cache, not the factory itself.

      Parameters:
      conf - configuration
      exceptionFactory - exception factory
      hostAddress - host address (used to resolve a per-host sslMode override)
      Returns:
      SSL socket factory
      Throws:
      SQLException - if the SSL context cannot be initialized
    • newSslSocketFactory

      static SSLSocketFactory newSslSocketFactory(KeyManager[] keyManagers, TrustManager[] trustManagers, ExceptionFactory exceptionFactory) throws SQLException
      Build a fresh SSLSocketFactory from the given managers. A new SSLContext is created on each call, so no client SSL session cache is shared between connections (no TLS session resumption across connections).
      Parameters:
      keyManagers - key managers (maybe null)
      trustManagers - trust managers
      exceptionFactory - exception factory
      Returns:
      a new SSL socket factory
      Throws:
      SQLException - if the SSL context cannot be initialized
    • createSocket

      default SSLSocket createSocket(Socket socket, SSLSocketFactory sslSocketFactory) throws IOException
      Returns a socket layered over an existing socket negotiating the use of SSL over an existing socket.
      Parameters:
      socket - existing socket
      sslSocketFactory - SSL socket factory
      Returns:
      SSL socket
      Throws:
      IOException - if any socket error occurs.
    • verify

      void verify(String host, SSLSession sslSession, long serverThreadId) throws SSLException
      Host name verifier implementation.
      Parameters:
      host - hostname
      sslSession - ssl session
      serverThreadId - current server threadId
      Throws:
      SSLException - if verification fail