Class MariaDbX509DeferredIdentityTrustManager
- All Implemented Interfaces:
TrustManager, X509TrustManager
It delegates the standard certificate-chain check to a real X509TrustManager. When
that check fails because the chain cannot be validated against the trust store, typically because
the server presented a self-signed certificate it generated on the fly (MariaDB does this when
TLS is enabled but no server certificate is configured), this manager does not reject the
connection. Instead, it records the leaf certificate fingerprint and lets the handshake proceed,
so the server's identity can be validated later, during authentication.
Identity is then proven cryptographically by the authentication plugin, which binds the session to this exact certificate (password + scramble + certificate fingerprint). A man-in-the-middle presenting a different certificate produces a different fingerprint, so authentication fails, the fingerprint is what actually validates the peer, not the (self-signed) certificate itself. A self-signed/ephemeral certificate is therefore only the usual trigger for this path, not the basis of the validation.
This only delays identity validation; it does not weaken it. Expired or not-yet-valid certificates are still rejected outright here, and this manager must only be used on connection paths that go on to perform fingerprint-based authentication.
A new instance is created per connection, wrapping a shared (cached) delegate, so the captured
fingerprint is simply per-connection instance state, read afterward via getFingerprint().
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMariaDbX509DeferredIdentityTrustManager(X509TrustManager javaTrustManager) Wraps a standardX509TrustManager, capturing the server certificate fingerprint when the chain cannot be validated normally so that identity can be verified later, during authentication. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckClientTrusted(X509Certificate[] x509Certificates, String authType) voidcheckServerTrusted(X509Certificate[] x509Certificates, String authType) byte[]Fingerprint of the server's leaf certificate, captured when the certificate could not be validated against the trust store and its identity must instead be verified during authentication.private static byte[]getThumbprint(X509Certificate cert)
-
Field Details
-
internal
-
fingerprint
private byte[] fingerprint
-
-
Constructor Details
-
MariaDbX509DeferredIdentityTrustManager
Wraps a standardX509TrustManager, capturing the server certificate fingerprint when the chain cannot be validated normally so that identity can be verified later, during authentication.- Parameters:
javaTrustManager- real trust manager
-
-
Method Details
-
getThumbprint
private static byte[] getThumbprint(X509Certificate cert) throws NoSuchAlgorithmException, CertificateEncodingException -
checkClientTrusted
public void checkClientTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException - Specified by:
checkClientTrustedin interfaceX509TrustManager- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException - Specified by:
checkServerTrustedin interfaceX509TrustManager- Throws:
CertificateException
-
getFingerprint
public byte[] getFingerprint()Fingerprint of the server's leaf certificate, captured when the certificate could not be validated against the trust store and its identity must instead be verified during authentication. Returnsnullwhen the certificate validated normally, so no deferred fingerprint check is needed.- Returns:
- captured fingerprint, or
null
-
getAcceptedIssuers
- Specified by:
getAcceptedIssuersin interfaceX509TrustManager
-