Hi Spring Team,
I am using the Spring boot 3.2.0, and my requirement is to set SslBundles in code instead of setting in YAML file .
so I am trying to use setSslBundles() in TomcatServletWebServerFactory as part of code below:
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory ( serverPort ) ;
SslBundle sslBundle = SslBundle.of (
SslStoreBundle.of (keyStore , password , trustStore));
DefaultSslBundleRegistry defaultSslBundleRegistry = new DefaultSslBundleRegistry ( ); defaultSslBundleRegistry.registerBundle ("test-bundle", sslBundle);
Ssl ssl = Ssl . forBundle ("test-bundle") ;
ssl.setEnabledProtocols ( new String [ ] { " TLSv1.2 " } ) ;
......
factory.setSsl(ssl);
factory.setPort(port);
factory.setSslBundles(defaultSslBundleRegistry);
...
After starting the spring boot application in debug mode, I can see sslBundles can be loaded to TomcatServletWebServerFactory, but then it will be override by the YAML file config, which will become empty since no sslbundle settings in yaml file . I couldn't find a proper way to solve the problem. Could you please share any suggestions ?
Comment From: philwebb
I'm not sure if we should consider this a bug, but it's certainly less than idea. We'll need to discuss it to see what our options are.
In the meantime, the code that applies those Ssl properties is in ServletWebServerFactoryCustomizer and could disable that by excluding the ServletWebServerFactoryAutoConfiguration class from auto-configuration.
Comment From: wilkinsona
This is a specific case of https://github.com/spring-projects/spring-boot/issues/24706.
Comment From: philwebb
Thanks @wilkinsona, I'll mark this one as duplicate.