We are using the below setter methods of class AbstractHttp11Protocol to configure mTLS in spring-boot based application. After upgrading the application to spring-boot 3, started facing some issues related to Tomcat. I am facing compilation errors and got to know that these methods have been removed in Tomcat 10.x version.
@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> containerCustomizer() {
return configurableEmbeddedServletContainer -> {
if (configurableEmbeddedServletContainer != null) {
TomcatServletWebServerFactory tomcatEmbeddedServletContainerFactory = configurableEmbeddedServletContainer;
tomcatEmbeddedServletContainerFactory.addAdditionalTomcatConnectors(additionalConnector(serverConfig()));
}
};
}
private Connector additionalConnector(ServerConfig serverConfig) {
SslConfig sslConfig = serverConfig.getSsl();
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
connector.setScheme(SCHEME);
connector.setSecure(true);
connector.setPort(serverConfig.getPort());
protocol.setSSLEnabled(true);
//getting complilation errors in below code
protocol.setKeystoreType(sslConfig.getKeyStoreType());
protocol.setKeystoreFile(sslConfig.getKeyStore());
protocol.setKeystorePass(String.valueOf(sslConfig.getKeyStorePassword()));
protocol.setKeyPass(String.valueOf(sslConfig.getKeyPassword()));
protocol.setTruststoreType(sslConfig.getTrustStoreType());
protocol.setTruststoreFile(sslConfig.getTrustStore());
protocol.setTruststorePass(String.valueOf(sslConfig.getTrustStorePW()));
protocol.setSSLProtocol(TLSV_1_2);
protocol.setClientAuth("true");
return connector;
}
Find below commit where changes have been made in AbstractHttp11Protocol class for Tomcat 10.x :-
Remove support for deprecated TLS configuration style
Error:-
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project xxx module: Compilation failure: Compilation failure: [ERROR] /controller/HttpsRequestFactory.java:[71,30] com.xxx.HttpsRequestFactory.SelectByAlias is not abstract and does not override abstract method chooseAlias(java.util.Map<java.lang.String,org.apache.hc.core5.ssl.PrivateKeyDetails>,javax.net.ssl.SSLParameters) in org.apache.hc.core5.ssl.PrivateKeyStrategy [ERROR] /controller/HttpsRequestFactory.java:[81,17] method does not override or implement a method from a supertype [ERROR] /authentication/TomcatConnectorAutoConfiguration.java:[57,25] cannot find symbol [ERROR] symbol: method setKeystoreType(java.lang.String) [ERROR] location: variable protocol of type org.apache.coyote.http11.Http11NioProtocol [ERROR] /authentication/TomcatConnectorAutoConfiguration.java:[58,25] cannot find symbol [ERROR] symbol: method setKeystoreFile(java.lang.String) [ERROR] location: variable protocol of type org.apache.coyote.http11.Http11NioProtocol [ERROR] /authentication/TomcatConnectorAutoConfiguration.java:[59,25] cannot find symbol [ERROR] symbol: method setKeystorePass(java.lang.String) [ERROR] location: variable protocol of type org.apache.coyote.http11.Http11NioProtocol [ERROR] /authentication/TomcatConnectorAutoConfiguration.java:[60,25] cannot find symbol [ERROR] symbol: method setKeyPass(java.lang.String) [ERROR] location: variable protocol of type org.apache.coyote.http11.Http11NioProtocol [ERROR] /authentication/TomcatConnectorAutoConfiguration.java:[61,25] cannot find symbol [ERROR] symbol: method setTruststoreType(java.lang.String) [ERROR] location: variable protocol of type org.apache.coyote.http11.Http11NioProtocol [ERROR] /authentication/TomcatConnectorAutoConfiguration.java:[62,25] cannot find symbol [ERROR] symbol: method setTruststoreFile(java.lang.String) [ERROR] location: variable protocol of type org.apache.coyote.http11.Http11NioProtocol [ERROR] /authentication/TomcatConnectorAutoConfiguration.java:[63,25] cannot find symbol [ERROR] symbol: method setTruststorePass(java.lang.String) [ERROR] location: variable protocol of type org.apache.coyote.http11.Http11NioProtocol [ERROR] /authentication/TomcatConnectorAutoConfiguration.java:[64,25] cannot find symbol [ERROR] symbol: method setSSLProtocol(java.lang.String) [ERROR] location: variable protocol of type org.apache.coyote.http11.Http11NioProtocol [ERROR] /authentication/TomcatConnectorAutoConfiguration.java:[65,25] cannot find symbol [ERROR] symbol: method setClientAuth(java.lang.String) [ERROR] location: variable protocol of type org.apache.coyote.http11.Http11NioProtocol
Please suggest if there is any alternative approach to configure these properties or how to use these methods in Tomcat 10.x.