Friday, January 20, 2017

java.security.KeyManagementException: Default SSLContext is initialized automatically

The default SSLContext is immutable. If you try to initiate it, it throws this exception.
SSLContext sc = SSLContext.getDefault();
sc.init(<the KeyManagers>, <the TrustManagers>, new SecureRandom());
The above code segment will throw the following exception.

java.security.KeyManagementException: Default SSLContext is initialized automatically
        at sun.security.ssl.SSLContextImpl$DefaultSSLContext.engineInit(SSLContextImpl.java:511)
        at javax.net.ssl.SSLContext.init(SSLContext.java:283)

To fix it, use a SSLContex associated with a specific protocol instead of using the default SSLContext. You can find all the SSLContext algorithm/protocol here.

For example

      SSLContext sc = SSLContext.getInstance("TLSv1.2"); 

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.
  

No comments:

Post a Comment