Closed
Description
I would like to use a custom TrustManager
, such as one that only accepts certain issuers, accept-all, etc.
With current SslManagerBundle
, I need to write something like this to use a custom TrustManager
:
TrustManager myTrustManager = ...
// Cannot use DefaultSslManagerBundle as it's package private
KeyManagerFactory keyManagerFactory = getDefaultKeyManagerFactory();
// using netty impl
TrustManagerFactory trustManagerFactory = new TrustManagerFactoryWrapper(myTrustManager);
SslManagerBundle sslManagerBundle = SslManagerBundle.of(keyManagerFactory, trustManagerFactory);
SslBundle sslBundle = SslBundle.of(SslStoreBundle.NONE, SslBundleKey.NONE, SslOptions.NONE,
SslBundle.DEFAULT_PROTOCOL, sslManagerBundle);
...
private KeyManagerFactory getDefaultKeyManagerFactory() {
String algorithm = KeyManagerFactory.getDefaultAlgorithm();
try {
return KeyManagerFactory.getInstance(algorithm);
}
catch (NoSuchAlgorithmException ex) {
throw new IllegalStateException("Could not load key manager factory: " + ex.getMessage(), ex);
}
}
This is a lot of boilerplate code just to use a custom TrustManager
.
It would be great if the SslManagerBundle
API could be improved to support custom TrustManager
usage without requiring a KeyManagerFactory
. This would simplify configuring SSL/TLS settings when custom TrustManager
configurations are needed.