Package org.consensusj.jsonrpc
Class CompositeTrustManager
java.lang.Object
org.consensusj.jsonrpc.CompositeTrustManager
- All Implemented Interfaces:
TrustManager
,X509TrustManager
A Trust Manager that adds a second trust store (key store) to the default trust store.
See: https://stackoverflow.com/questions/48790981/load-java-trust-store-at-runtime-after-jvm-have-been-launched/58695061#58695061
-
Constructor Summary
ConstructorDescriptionCompositeTrustManager
(InputStream trustStoreStream) CompositeTrustManager
(Path trustStorePath) -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkClientTrusted
(X509Certificate[] chain, String authType) void
checkServerTrusted
(X509Certificate[] chain, String authType) static SSLContext
getAlternateSSLContext
(InputStream trustStoreStream) Create an SSLContext using an alternative Trust Storestatic SSLContext
getAlternateSSLContext
(Path trustStorePath) Create an SSLContext using an alternative Trust Storestatic SSLContext
getCompositeSSLContext
(InputStream trustStoreStream) Used to create an SSLContext usingCompositeTrustManager
See: https://stackoverflow.com/questions/859111/how-can-i-use-different-certificates-on-specific-connectionsstatic SSLContext
getCompositeSSLContext
(Path trustStorePath) Used to create an SSLContext usingCompositeTrustManager
See: https://stackoverflow.com/questions/859111/how-can-i-use-different-certificates-on-specific-connections
-
Constructor Details
-
CompositeTrustManager
- Parameters:
trustStoreStream
- Input stream for Java keystore with additional certificates
-
CompositeTrustManager
- Parameters:
trustStorePath
- Path to a Java keystore with additional certificates- Throws:
FileNotFoundException
- If the file doesn't exist
-
-
Method Details
-
getCompositeSSLContext
public static SSLContext getCompositeSSLContext(Path trustStorePath) throws NoSuchAlgorithmException, KeyManagementException, FileNotFoundException Used to create an SSLContext usingCompositeTrustManager
See: https://stackoverflow.com/questions/859111/how-can-i-use-different-certificates-on-specific-connections -
getCompositeSSLContext
public static SSLContext getCompositeSSLContext(InputStream trustStoreStream) throws NoSuchAlgorithmException, KeyManagementException Used to create an SSLContext usingCompositeTrustManager
See: https://stackoverflow.com/questions/859111/how-can-i-use-different-certificates-on-specific-connections -
getAlternateSSLContext
public static SSLContext getAlternateSSLContext(Path trustStorePath) throws KeyStoreException, IOException, NoSuchAlgorithmException, KeyManagementException, CertificateException Create an SSLContext using an alternative Trust Store -
getAlternateSSLContext
public static SSLContext getAlternateSSLContext(InputStream trustStoreStream) throws KeyStoreException, IOException, NoSuchAlgorithmException, KeyManagementException, CertificateException Create an SSLContext using an alternative Trust Store- Parameters:
trustStoreStream
- inputStream with Trust Store (password must be 'changeit')- Throws:
KeyStoreException
IOException
NoSuchAlgorithmException
KeyManagementException
CertificateException
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException - Specified by:
checkClientTrusted
in interfaceX509TrustManager
- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException - Specified by:
checkServerTrusted
in interfaceX509TrustManager
- Throws:
CertificateException
-
getAcceptedIssuers
- Specified by:
getAcceptedIssuers
in interfaceX509TrustManager
-