I read this very useful article about disabling all the https certificates programmatically. I need such approach only in the development. And I\'m using Spring. So does any
Yes - you can use init-method
attribute. Look at Initialization callbacks. But this interface is not enough. I suggest simply placing this code
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
In your custom class which will know that you are in dev mode or wchich will have such init-method.
BTW calling getSocketFactory
is simple - this is simply getting socketFactory
property.