-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Make it easier to provide custom TrustManagers in SslManagerBundle #43064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
So, something like this on /**
* Factory method to create a new {@link SslManagerBundle} using the given
* {@link TrustManagerFactory} and the default {@link KeyManagerFactory}.
* @param trustManagerFactory the trust manager factory
* @return a new {@link SslManagerBundle} instance
* @since 3.5.0
*/
static SslManagerBundle from(TrustManagerFactory trustManagerFactory) {
Assert.notNull(trustManagerFactory, "TrustManagerFactory must not be null");
KeyManagerFactory defaultKeyManagerFactory = createDefaultKeyManagerFactory();
return of(defaultKeyManagerFactory, trustManagerFactory);
}
/**
* Factory method to create a new {@link SslManagerBundle} using the given
* {@link TrustManager TrustManagers} and the default {@link KeyManagerFactory}.
* @param trustManagers the trust managers to use
* @return a new {@link SslManagerBundle} instance
* @since 3.5.0
*/
static SslManagerBundle from(TrustManager... trustManagers) {
Assert.notNull(trustManagers, "TrustManagers must not be null");
KeyManagerFactory defaultKeyManagerFactory = createDefaultKeyManagerFactory();
TrustManagerFactory defaultTrustManagerFactory = createDefaultTrustManagerFactory();
return of(defaultKeyManagerFactory, FixedTrustManagerFactory.of(defaultTrustManagerFactory, trustManagers));
} The You can then invoke it like this: SslBundle bundle = SslBundle.of(SslStoreBundle.NONE, SslBundleKey.NONE, SslOptions.NONE, SslBundle.DEFAULT_PROTOCOL, SslManagerBundle.from(myTrustManager)); You can play around with it here: https://github.com/mhalbritter/spring-boot/tree/mh/43064-provide-user-friendly-api-to-use-custom-trustmanager-in-ssl-manager-bundle |
Thanks @mhalbritter |
Hi @mhalbritter I played around with multiple Sample:
Therefore, the method here which accepts multiple trust-managers, doesn't really use them. The check only happened by the first trust-manager, and if it throws So, the new API on static SslManagerBundle from(TrustManager... trustManagers) { should be only accepting a single static SslManagerBundle from(TrustManager trustManager) { |
Hey @ttddyy, the TrustManager[] engineGetTrustManagers() So I think it makes sense to allow multiple |
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 customTrustManager
: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 customTrustManager
usage without requiring aKeyManagerFactory
. This would simplify configuring SSL/TLS settings when customTrustManager
configurations are needed.The text was updated successfully, but these errors were encountered: