Class DefaultTlsSocketPlugin

  • All Implemented Interfaces:
    TlsSocketPlugin

    public class DefaultTlsSocketPlugin
    extends java.lang.Object
    implements TlsSocketPlugin
    Default TLS socket plugin
    • Field Detail

      • logger

        private static final Logger logger
      • KEY_CACHE

        private static final java.util.concurrent.ConcurrentHashMap<java.lang.String,​javax.net.ssl.KeyManager[]> KEY_CACHE
    • Constructor Detail

      • DefaultTlsSocketPlugin

        public DefaultTlsSocketPlugin()
    • Method Detail

      • cacheDisabled

        private static boolean cacheDisabled​(Configuration conf)
        Non-mapped option disableSslContextCache to disable the trust/key-manager cache and rebuild the managers on every connection.
      • loadClientCerts

        private static javax.net.ssl.KeyManager loadClientCerts​(java.lang.String keyStoreUrl,
                                                                java.lang.String keyStorePassword,
                                                                java.lang.String keyPassword,
                                                                java.lang.String storeType,
                                                                ExceptionFactory exceptionFactory)
                                                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • loadFromUrl

        private static java.io.InputStream loadFromUrl​(java.lang.String keyStoreUrl)
                                                throws java.io.FileNotFoundException
        Throws:
        java.io.FileNotFoundException
      • getInputStreamFromPath

        private static java.io.InputStream getInputStreamFromPath​(java.lang.String path)
                                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • type

        public java.lang.String type()
        Description copied from interface: TlsSocketPlugin
        plugin type.
        Specified by:
        type in interface TlsSocketPlugin
        Returns:
        plugin type
      • buildTrustManager

        javax.net.ssl.TrustManager[] buildTrustManager​(Configuration conf,
                                                       ExceptionFactory exceptionFactory,
                                                       HostAddress hostAddress)
                                                throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • wrapTrust

        private static javax.net.ssl.TrustManager[] wrapTrust​(DefaultTlsSocketPlugin.CachedTrust cachedTrust)
        Wraps the cached base trust manager for a single connection: paths that defer identity validation to authentication get a fresh MariaDbX509DeferredIdentityTrustManager (so the captured fingerprint is per-connection state); other paths use the stateless base directly.
      • buildKeyManager

        javax.net.ssl.KeyManager[] buildKeyManager​(Configuration conf,
                                                   ExceptionFactory exceptionFactory)
                                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • keyCacheKey

        private static java.lang.String keyCacheKey​(Configuration conf)
      • appendValue

        private static void appendValue​(java.lang.StringBuilder sb,
                                        java.lang.String value)
      • appendFile

        private static void appendFile​(java.lang.StringBuilder sb,
                                       java.lang.String value)
      • freshnessToken

        private static java.lang.String freshnessToken​(java.lang.String value)
        Freshness token for a store reference. For a local file it is last-modified + length, so an on-disk replacement invalidates the cache. Inline PEM is its own token (content addressed). Remote/classpath references cannot be checked cheaply and are tracked by their string only.
      • toFile

        private static java.io.File toFile​(java.lang.String value)
      • sha256

        private static java.lang.String sha256​(java.lang.String input)
      • verify

        public void verify​(java.lang.String host,
                           javax.net.ssl.SSLSession session,
                           long serverThreadId)
                    throws javax.net.ssl.SSLException
        Description copied from interface: TlsSocketPlugin
        Host name verifier implementation.
        Specified by:
        verify in interface TlsSocketPlugin
        Parameters:
        host - hostname
        session - ssl session
        serverThreadId - current server threadId
        Throws:
        javax.net.ssl.SSLException - if verification fail