Class ReloadableSslContext
java.lang.Object
com.loomcache.common.config.ReloadableSslContext
Thread-safe wrapper around
SSLContext that supports hot-reload of certificates.
Delegates all operations to the current SSLContext via an AtomicReference.
When certificates are reloaded, the reference is atomically updated.
Existing connections continue using the old context (SSLEngine holds a copy). New connections will use the newly loaded context.
Note: This class uses delegation rather than inheritance because SSLContext
methods such as createSSLEngine are final starting from JDK 24.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionReloadableSslContext(SSLContext initialContext) Create a reloadable SSL context wrapper. -
Method Summary
Modifier and TypeMethodDescriptionCreate an SSLEngine for a client connection.createSSLEngine(String peerHost, int peerPort) Create an SSLEngine for a client connection with specified host and port.Get the default SSL session context for client connections.Get the underlying (current) SSLContext.Get the default SSL session context for server connections.voidreload(SSLContext newContext) Atomically reload with a new SSLContext.
-
Constructor Details
-
ReloadableSslContext
Create a reloadable SSL context wrapper.- Parameters:
initialContext- the initial SSLContext to wrap- Throws:
NullPointerException- ifinitialContextis null
-
-
Method Details
-
reload
Atomically reload with a new SSLContext. Existing connections will continue using their original context. New connections will use the newly set context.- Parameters:
newContext- the new SSLContext to use for new connections- Throws:
NullPointerException- ifnewContextis null
-
createSSLEngine
-
createSSLEngine
Create an SSLEngine for a client connection with specified host and port. Uses the current SSLContext.- Parameters:
peerHost- the non-authoritative name of the hostpeerPort- the non-authoritative port- Returns:
- a new
SSLEnginefrom the current context
-
getClientSessionContext
Get the default SSL session context for client connections.- Returns:
- the client
SSLSessionContext
-
getServerSessionContext
Get the default SSL session context for server connections.- Returns:
- the server
SSLSessionContext
-
getDelegate
Get the underlying (current) SSLContext. Useful for operations that need direct access (like socket creation).- Returns:
- the current
SSLContextdelegate
-