Class OpenSslCachingKeyMaterialProvider
java.lang.Object
io.netty.handler.ssl.OpenSslKeyMaterialProvider
io.netty.handler.ssl.OpenSslCachingKeyMaterialProvider
OpenSslKeyMaterialProvider that will cache the OpenSslKeyMaterial to reduce the overhead
of parsing the chain and the key for generation of the material.
Cache reads are lock-free (ConcurrentHashMap.get(Object) + retain());
if a concurrent eviction releases the material in between, retain()
detects the dead reference count and the read falls back to a cache miss.
Mutations (insert, evict, destroy) use ConcurrentHashMap.compute(K, BiFunction) /
ConcurrentHashMap.computeIfPresent(K, BiFunction) for atomicity.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentHashMap<String, OpenSslKeyMaterial> private booleanprivate final int -
Constructor Summary
ConstructorsConstructorDescriptionOpenSslCachingKeyMaterialProvider(X509KeyManager keyManager, String password, int maxEntries) -
Method Summary
Modifier and TypeMethodDescription(package private) int(package private) OpenSslKeyMaterialchooseKeyMaterial(ByteBufAllocator allocator, String alias) Returns theOpenSslKeyMaterialornull(if none) that should be used during the handshake by OpenSSL.(package private) voiddestroy()Will be invoked once the provider should be destroyed.private voidprivate OpenSslKeyMaterialgetAndRetain(String alias) Lock-free cache lookup.private OpenSslKeyMaterialputIfAbsentAndRetain(String alias, OpenSslKeyMaterial material) Atomically inserts material if absent, or retains the existing entry.private voidremoveAndRelease(String alias) Atomically removes and releases the entry for the given alias.private voidMethods inherited from class OpenSslKeyMaterialProvider
keyManager, validateKeyMaterialSupported
-
Field Details
-
maxCachedEntries
private final int maxCachedEntries -
cache
-
destroyed
private volatile boolean destroyed
-
-
Constructor Details
-
OpenSslCachingKeyMaterialProvider
OpenSslCachingKeyMaterialProvider(X509KeyManager keyManager, String password, int maxEntries)
-
-
Method Details
-
getAndRetain
Lock-free cache lookup. If a concurrent eviction releases the material betweengetandretain, the dead reference count is detected and treated as a cache miss. -
putIfAbsentAndRetain
Atomically inserts material if absent, or retains the existing entry. -
removeAndRelease
Atomically removes and releases the entry for the given alias. -
evictStaleEntries
private void evictStaleEntries() -
chooseKeyMaterial
Description copied from class:OpenSslKeyMaterialProviderReturns theOpenSslKeyMaterialornull(if none) that should be used during the handshake by OpenSSL.- Overrides:
chooseKeyMaterialin classOpenSslKeyMaterialProvider- Throws:
Exception
-
cacheSize
int cacheSize() -
destroy
void destroy()Description copied from class:OpenSslKeyMaterialProviderWill be invoked once the provider should be destroyed.- Overrides:
destroyin classOpenSslKeyMaterialProvider
-
removeAndReleaseAllEntries
private void removeAndReleaseAllEntries()
-