So after all, it seems there is no simple way to tell spring boot to use dashes instead of dots.
I finally ended up writing a custom DataSource
in my MainConfig as well as a custom ServletWebServerFactory
to set all the ssl properties for tomcat.
For the case that someone ends up here, looking for a solution to this or a similar problem I'll post some code snippets that might help.
Code for DataSource (I read all the common properties from application properties using the dot-notation, just username and password are read from KeyVault):
@Value("${db-user}")
String dbUser;
@Value("${db-password}")
String dbPwd;
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource getDataSource() {
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.username(dbUser);
dataSourceBuilder.password(dbPwd);
return dataSourceBuilder.build();
}
Code for ServletWebServerFactory (all the used values are injected as above using @Value
-annotation):
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
TomcatConnectorCustomizer tomcatConnectorCustomizer = connector -> {
connector.setPort(port);
connector.setScheme("https");
connector.setSecure(true);
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
protocol.setSSLEnabled(true);
protocol.setKeystoreType(keyStoreType);
protocol.setKeystoreProvider(keyStoreProvider);
protocol.setKeystoreFile(keyStorePath);
protocol.setKeystorePass(keyStorePassword);
protocol.setKeyAlias(keyAlias);
protocol.setTruststoreFile(trustStorePath);
protocol.setTruststorePass(trustStorePassword);
protocol.setSSLVerifyClient(clientAuth);
};
tomcat.addConnectorCustomizers(tomcatConnectorCustomizer);
return tomcat;
}
There where some other places where I had to use something similar, but as this was specially for our solution I won't post it here. I think you might get the idea how to solve things like this from the posted code.