Package org.mariadb.jdbc.plugin
Interface TlsSocketPlugin
- All Known Implementing Classes:
DefaultTlsSocketPlugin
public interface TlsSocketPlugin
TLS Socket interface plugin
-
Method Summary
Modifier and TypeMethodDescriptiondefault SSLSocketcreateSocket(Socket socket, SSLSocketFactory sslSocketFactory) Returns a socket layered over an existing socket negotiating the use of SSL over an existing socket.getKeyManager(Configuration conf, ExceptionFactory exceptionFactory) default SSLSocketFactorygetSocketFactory(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) Build anSSLSocketFactoryfor the given configuration.getTrustManager(Configuration conf, ExceptionFactory exceptionFactory, HostAddress hostAddress) static SSLSocketFactorynewSslSocketFactory(KeyManager[] keyManagers, TrustManager[] trustManagers, ExceptionFactory exceptionFactory) Build a freshSSLSocketFactoryfrom the given managers.type()plugin type.voidverify(String host, SSLSession sslSession, long serverThreadId) Host name verifier implementation.
-
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 anSSLSocketFactoryfor the given configuration.A fresh
SSLContextis 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- configurationexceptionFactory- exception factoryhostAddress- 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 freshSSLSocketFactoryfrom the given managers. A newSSLContextis created on each call, so no client SSL session cache is shared between connections (no TLS session resumption across connections).- Parameters:
keyManagers- key managers (maybenull)trustManagers- trust managersexceptionFactory- exception factory- Returns:
- a new SSL socket factory
- Throws:
SQLException- if the SSL context cannot be initialized
-
createSocket
Returns a socket layered over an existing socket negotiating the use of SSL over an existing socket.- Parameters:
socket- existing socketsslSocketFactory- SSL socket factory- Returns:
- SSL socket
- Throws:
IOException- if any socket error occurs.
-
verify
Host name verifier implementation.- Parameters:
host- hostnamesslSession- ssl sessionserverThreadId- current server threadId- Throws:
SSLException- if verification fail
-