Class DefaultTlsSocketPlugin
java.lang.Object
org.mariadb.jdbc.plugin.tls.main.DefaultTlsSocketPlugin
- All Implemented Interfaces:
TlsSocketPlugin
Default TLS socket plugin
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ConcurrentHashMap<String, KeyManager[]> private static final Loggerprivate static final intprivate static final ConcurrentHashMap<String, DefaultTlsSocketPlugin.CachedTrust> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidappendFile(StringBuilder sb, String value) private static voidappendValue(StringBuilder sb, String value) (package private) KeyManager[]buildKeyManager(Configuration conf, ExceptionFactory exceptionFactory) buildTrust(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) (package private) TrustManager[]buildTrustManager(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) private static booleancacheDisabled(Configuration conf) Non-mapped optiondisableSslContextCacheto disable the trust/key-manager cache and rebuild the managers on every connection.private static StringfreshnessToken(String value) Freshness token for a store reference.private static InputStreamgetInputStreamFromPath(String path) getKeyManager(Configuration conf, ExceptionFactory exceptionFactory) getTrustManager(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) private static StringkeyCacheKey(Configuration conf) private static KeyManagerloadClientCerts(String keyStoreUrl, String keyStorePassword, String keyPassword, String storeType, ExceptionFactory exceptionFactory) private static InputStreamloadFromUrl(String keyStoreUrl) private static Stringprivate static Fileprivate static StringtrustCacheKey(Configuration conf, HostAddress hostAddress) Cache key for the trust managers.type()plugin type.voidverify(String host, SSLSession session, long serverThreadId) Host name verifier implementation.private static TrustManager[]wrapTrust(DefaultTlsSocketPlugin.CachedTrust cachedTrust) Wraps the cached base trust manager for a single connection: paths that defer identity validation to authentication get a freshMariaDbX509DeferredIdentityTrustManager(so the captured fingerprint is per-connection state); other paths use the stateless base directly.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TlsSocketPlugin
createSocket, getSocketFactory
-
Field Details
-
logger
-
TRUST_CACHE
-
KEY_CACHE
-
MAX_CACHE_SIZE
private static final int MAX_CACHE_SIZE- See Also:
-
-
Constructor Details
-
DefaultTlsSocketPlugin
public DefaultTlsSocketPlugin()
-
-
Method Details
-
cacheDisabled
Non-mapped optiondisableSslContextCacheto disable the trust/key-manager cache and rebuild the managers on every connection. -
loadClientCerts
private static KeyManager loadClientCerts(String keyStoreUrl, String keyStorePassword, String keyPassword, String storeType, ExceptionFactory exceptionFactory) throws SQLException - Throws:
SQLException
-
loadFromUrl
- Throws:
FileNotFoundException
-
getInputStreamFromPath
- Throws:
IOException
-
type
Description copied from interface:TlsSocketPluginplugin type.- Specified by:
typein interfaceTlsSocketPlugin- Returns:
- plugin type
-
getTrustManager
public TrustManager[] getTrustManager(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) throws SQLException - Specified by:
getTrustManagerin interfaceTlsSocketPlugin- Throws:
SQLException
-
buildTrustManager
TrustManager[] buildTrustManager(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) throws SQLException - Throws:
SQLException
-
wrapTrust
Wraps the cached base trust manager for a single connection: paths that defer identity validation to authentication get a freshMariaDbX509DeferredIdentityTrustManager(so the captured fingerprint is per-connection state); other paths use the stateless base directly. -
buildTrust
private DefaultTlsSocketPlugin.CachedTrust buildTrust(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) throws SQLException - Throws:
SQLException
-
getKeyManager
public KeyManager[] getKeyManager(Configuration conf, ExceptionFactory exceptionFactory) throws SQLException - Specified by:
getKeyManagerin interfaceTlsSocketPlugin- Throws:
SQLException
-
buildKeyManager
KeyManager[] buildKeyManager(Configuration conf, ExceptionFactory exceptionFactory) throws SQLException - Throws:
SQLException
-
trustCacheKey
Cache key for the trust managers. The options read bybuildTrustManager(Configuration, ExceptionFactory, HostAddress). A store referenced by a file path contributes a freshness token (last-modified + length) so replacing it on disk forces a rebuild. The system trust store used by the fallback path is identified by thejavax.net.ssl.trustStoreproperty (+ token). The key is hashed so that store passwords are not retained as plain text in a long-lived map. -
keyCacheKey
-
appendValue
-
appendFile
-
freshnessToken
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
-
sha256
-
verify
Description copied from interface:TlsSocketPluginHost name verifier implementation.- Specified by:
verifyin interfaceTlsSocketPlugin- Parameters:
host- hostnamesession- ssl sessionserverThreadId- current server threadId- Throws:
SSLException- if verification fail
-