I am looking to override the SSLContext of Spring at runtime. Hence I am trying to find ways to register the below method as a bean dynamically.
For Ex. When a GetMapping endpoint is invoked, the below method should be injected as a bean into Spring IoC.
public static SSLContext getSSLContext() throws Exception {
TrustManager[] trustManagers = new TrustManager[] {
new ReloadableX509TrustManager(truststoreNewPath)
};
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustManagers, null);
return sslContext;
}
How can I do this?