Module nl.altindag.ssl
Package nl.altindag.ssl.trustmanager
Class InflatableX509ExtendedTrustManager
java.lang.Object
javax.net.ssl.X509ExtendedTrustManager
nl.altindag.ssl.trustmanager.DelegatingTrustManager<X509ExtendedTrustManager>
nl.altindag.ssl.trustmanager.DelegatingX509ExtendedTrustManager
nl.altindag.ssl.trustmanager.HotSwappableX509ExtendedTrustManager
nl.altindag.ssl.trustmanager.InflatableX509ExtendedTrustManager
- All Implemented Interfaces:
TrustManager,X509TrustManager
NOTE:
Please don't use this class directly as it is part of the internal API. Class name and methods can be changed any time.
Instead use the
TrustManagerUtils which provides the same functionality
while it has a stable API because it is part of the public API.
The Inflatable TrustManager has the capability to grow with newly trusted certificates at any moment in time.
It can be either added manually with TrustManagerUtils.addCertificate(X509ExtendedTrustManager, List) or by providing
a predicate in the constructor of this class so it can evaluate every certificate whether it should be trusted or not.
Next to that it will write the trusted certificates to the file system as a keystore file if the properties are provided in the
constructor. If this is not the case it will still use an in-memory keystore to maintain the newly added certificates, however
the state will get lost when the application has been restarted.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final BiPredicate<KeyStore, X509Certificate> private static final nl.altindag.sude.Loggerprivate final Predicate<TrustManagerParameters> private final KeyStoreprivate final char[]private final PathFields inherited from class nl.altindag.ssl.trustmanager.HotSwappableX509ExtendedTrustManager
readLock, writeLockFields inherited from class nl.altindag.ssl.trustmanager.DelegatingTrustManager
trustManager -
Constructor Summary
ConstructorsConstructorDescriptionInflatableX509ExtendedTrustManager(Path trustStorePath, char[] trustStorePassword, String trustStoreType, Predicate<TrustManagerParameters> trustManagerParametersPredicate) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCertificates(List<X509Certificate> certificates) private voidaddCertificates(List<X509Certificate> certificates, BiPredicate<KeyStore, X509Certificate> duplicateChecker) voidcheckClientTrusted(X509Certificate[] chain, String authType) voidcheckClientTrusted(X509Certificate[] chain, String authType, Socket socket) voidcheckClientTrusted(X509Certificate[] chain, String authType, SSLEngine sslEngine) voidcheckServerTrusted(X509Certificate[] chain, String authType) voidcheckServerTrusted(X509Certificate[] chain, String authType, Socket socket) voidcheckServerTrusted(X509Certificate[] chain, String authType, SSLEngine sslEngine) private voidcheckTrusted(TrustManagerRunnable trustManagerRunnable, X509Certificate[] chain, String authType, Socket socket, SSLEngine sslEngine) private StringgenerateAlias(Certificate certificate) Methods inherited from class nl.altindag.ssl.trustmanager.HotSwappableX509ExtendedTrustManager
getAcceptedIssuers, getInnerTrustManager, setTrustManager
-
Field Details
-
LOGGER
private static final nl.altindag.sude.Logger LOGGER -
IGNORE_DUPLICATE_CHECKER
-
trustStore
-
trustStorePath
-
trustStorePassword
private final char[] trustStorePassword -
trustManagerParametersPredicate
-
-
Constructor Details
-
InflatableX509ExtendedTrustManager
public InflatableX509ExtendedTrustManager() -
InflatableX509ExtendedTrustManager
public InflatableX509ExtendedTrustManager(Path trustStorePath, char[] trustStorePassword, String trustStoreType, Predicate<TrustManagerParameters> trustManagerParametersPredicate)
-
-
Method Details
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException - Specified by:
checkServerTrustedin interfaceX509TrustManager- Overrides:
checkServerTrustedin classHotSwappableX509ExtendedTrustManager- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException - Overrides:
checkServerTrustedin classHotSwappableX509ExtendedTrustManager- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine sslEngine) throws CertificateException - Overrides:
checkServerTrustedin classHotSwappableX509ExtendedTrustManager- Throws:
CertificateException
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException - Specified by:
checkClientTrustedin interfaceX509TrustManager- Overrides:
checkClientTrustedin classHotSwappableX509ExtendedTrustManager- Throws:
CertificateException
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException - Overrides:
checkClientTrustedin classHotSwappableX509ExtendedTrustManager- Throws:
CertificateException
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine sslEngine) throws CertificateException - Overrides:
checkClientTrustedin classHotSwappableX509ExtendedTrustManager- Throws:
CertificateException
-
checkTrusted
private void checkTrusted(TrustManagerRunnable trustManagerRunnable, X509Certificate[] chain, String authType, Socket socket, SSLEngine sslEngine) throws CertificateException - Throws:
CertificateException
-
addCertificates
-
addCertificates
private void addCertificates(List<X509Certificate> certificates, BiPredicate<KeyStore, X509Certificate> duplicateChecker) -
generateAlias
-
getTrustStorePath
-