Reputation: 345
Spring boot doesn't pick my custom trust manager instance, even though I install it before the tomcat boots up.
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[] { trustManager }, null);
SSLContext.setDefault(sslContext);
Does boot shadow the default SSL settings?
Is there a way to overrule this?
Upvotes: 0
Views: 2240
Reputation: 28566
Put Your SSL config in @PostConstruct
. Method with this annotation will be called by Spring container after bean creation by dependency injection mechanism.
@Component
public class SomeComponent {
@PostConstruct
public void sslContextConfiguration() {
try {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[] { trustManager }, null);
SSLContext.setDefault(sslContext);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Upvotes: 2