Class CertificateReloader
java.lang.Object
com.loomcache.common.config.CertificateReloader
Handles certificate reloading with validation and metrics.
Loads new keystores/truststores from disk, validates them before switching, and atomically swaps the SSLContext. Tracks metrics like reload count and certificate expiration warnings.
-
Constructor Summary
ConstructorsConstructorDescriptionCertificateReloader(TlsConfig tlsConfig, ReloadableSslContext reloadableSslContext) Create a certificate reloader. -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck all certificates and log upcoming expirations.longGet days until the earliest certificate expires.longGet the timestamp of the last successful reload (ms since epoch).Get human-readable expiration time of the earliest certificate.longGet the Unix timestamp (ms) when the earliest certificate expires.intGet the number of successful reloads.voidreload()Reload certificates from disk, validate, and swap SSLContext.
-
Constructor Details
-
CertificateReloader
Create a certificate reloader.- Parameters:
tlsConfig- TLS configuration (must not be null)reloadableSslContext- the SSL context wrapper to update (must not be null)
-
-
Method Details
-
reload
public void reload()Reload certificates from disk, validate, and swap SSLContext.Existing connections continue using the old context. New connections will use the newly loaded context. Errors are logged but do not crash.
-
checkCertificateExpiration
public void checkCertificateExpiration()Check all certificates and log upcoming expirations. Called periodically or on-demand. -
getReloadCount
public int getReloadCount()Get the number of successful reloads. -
getLastReloadTimeMs
public long getLastReloadTimeMs()Get the timestamp of the last successful reload (ms since epoch). Returns 0 if no reload has occurred yet. -
getNextCertExpiryMs
public long getNextCertExpiryMs()Get the Unix timestamp (ms) when the earliest certificate expires. Returns Long.MAX_VALUE if unknown. -
getNextCertExpiryFormatted
Get human-readable expiration time of the earliest certificate. -
getDaysUntilExpiry
public long getDaysUntilExpiry()Get days until the earliest certificate expires. Returns 0 if already expired or unknown.
-