Package org.apache.cassandra.security
Class FileBasedSslContextFactory
java.lang.Object
org.apache.cassandra.security.AbstractSslContextFactory
org.apache.cassandra.security.FileBasedSslContextFactory
- All Implemented Interfaces:
ISslContextFactory
- Direct Known Subclasses:
DefaultSslContextFactory,PEMBasedSslContextFactory
Abstract implementation for
ISslContextFactory using file based, standard keystore format with the ability
to hot-reload the files upon file changes (detected by the last modified timestamp).
CAUTION: While this is a useful abstraction, please be careful if you need to modify this class
given possible custom implementations out there!
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classHelper class for hot reloading SSL ContextsNested classes/interfaces inherited from interface org.apache.cassandra.security.ISslContextFactory
ISslContextFactory.SocketType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<FileBasedSslContextFactory.HotReloadableFile>List of files that trigger hot reloading of SSL certificatesFields inherited from class org.apache.cassandra.security.AbstractSslContextFactory
accepted_protocols, algorithm, cipher_suites, enabled, openSslIsAvailable, optional, parameters, protocol, require_client_auth, require_endpoint_verification, store_type, TLS_PROTOCOL_SUBSTITUTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected KeyManagerFactoryBuilds required KeyManagerFactory from the file based keystore.protected KeyManagerFactoryCreate aKeyManagerFactoryfor outbound connections.protected TrustManagerFactoryBuilds TrustManagerFactory from the file based truststore.protected booleanbooleanReturns if this factory uses private keystore.booleanReturns if this factory uses outbound keystore.voidInitializes hot reloading of the security keys/certs.booleanReturns if any changes require the reloading of the SSL context returned by this factory.protected voidvalidatePassword(boolean isOutboundKeystore, String password) Validates the given keystore password.Methods inherited from class org.apache.cassandra.security.AbstractSslContextFactory
createJSSESslContext, createNettySslContext, deriveIfOpenSslAvailable, getAcceptedProtocols, getBoolean, getBoolean, getCipherSuites, getSslProvider, getString, getString, getStringList
-
Field Details
-
keystoreContext
-
outboundKeystoreContext
-
trustStoreContext
-
hotReloadableFiles
List of files that trigger hot reloading of SSL certificates
-
-
Constructor Details
-
FileBasedSslContextFactory
public FileBasedSslContextFactory() -
FileBasedSslContextFactory
-
-
Method Details
-
shouldReload
public boolean shouldReload()Description copied from interface:ISslContextFactoryReturns if any changes require the reloading of the SSL context returned by this factory. This will be called by Cassandra's periodic polling for any potential changes that will reload the SSL context. However only newer connections established after the reload will use the reloaded SSL context.- Returns:
trueif SSL Context needs to be reload;falseotherwise
-
hasKeystore
public boolean hasKeystore()Description copied from interface:ISslContextFactoryReturns if this factory uses private keystore.- Returns:
trueby default unless the implementation overrides this
-
hasOutboundKeystore
public boolean hasOutboundKeystore()Description copied from interface:ISslContextFactoryReturns if this factory uses outbound keystore.- Returns:
trueby default unless the implementation overrides this
-
initHotReloading
public void initHotReloading()Description copied from interface:ISslContextFactoryInitializes hot reloading of the security keys/certs. The implementation must guarantee this to be thread safe. -
validatePassword
Validates the given keystore password.- Parameters:
isOutboundKeystore-truefor theoutbound_keystore_password;falseotherwisepassword- value- Throws:
IllegalArgumentException- if thepasswordis null
-
buildKeyManagerFactory
Builds required KeyManagerFactory from the file based keystore. It also checks for the PrivateKey's certificate's expiry and logswarningfor each expired PrivateKey's certitificate.- Specified by:
buildKeyManagerFactoryin classAbstractSslContextFactory- Returns:
- KeyManagerFactory built from the file based keystore.
- Throws:
SSLException- if any issues encountered during the build processIllegalArgumentException- if the validation for thekeystore_passwordfails- See Also:
-
buildOutboundKeyManagerFactory
Description copied from class:AbstractSslContextFactoryCreate aKeyManagerFactoryfor outbound connections. It provides a seperate keystore for internode mTLS outbound connections.- Specified by:
buildOutboundKeyManagerFactoryin classAbstractSslContextFactory- Returns:
KeyManagerFactory- Throws:
SSLException
-
buildTrustManagerFactory
Builds TrustManagerFactory from the file based truststore.- Specified by:
buildTrustManagerFactoryin classAbstractSslContextFactory- Returns:
- TrustManagerFactory from the file based truststore
- Throws:
SSLException- if any issues encountered during the build process
-
checkExpiredCerts
- Throws:
KeyStoreException
-