I am in the impression that once I set system properties when I get SSLContext.getDefault() should return me SSLContext with those set properties. In the following case should be with specified keyStore. Unfortunately that's not what is happening. It falls back JVM's default keystore. Am I missing something ?
System.setProperty("javax.net.ssl.keyStore", "/valida-location/keyStore.jks");
System.setProperty("javax.net.ssl.keyStorePassword","changeit");
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
answer = SSLContext.getDefault();
I think by the time
answer = SSLContext.getDefault();
was about to execute, SSLContext related classed were already loaded. I solved it by puttingSystem.setProperty("javax.net.ssl.keyStore", "/valida-location/keyStore.jks"); System.setProperty("javax.net.ssl.keyStorePassword","changeit");
in static block of my class. That way, there properties were set at the time of class loading. Thanks to @dave_thompson_085 for hint.