You will have to create an SSLContext
to set the Protocoll:
in Java 1.8:
SSLContext sc = SSLContext.getInstance("TLSv1.2");
// Init the SSLContext with a TrustManager[] and SecureRandom()
sc.init(null, trustCerts, new java.security.SecureRandom());
in Java 1.7:
SSLContext sc = SSLContext.getInstance("TLSv1");
// Init the SSLContext with a TrustManager[] and SecureRandom()
sc.init(null, trustCerts, new java.security.SecureRandom());
then you just have to set the SSLContext to the HttpsURLConnection:
httpsCon.setSSLSocketFactory(sc.getSocketFactory());
That should do the Trick.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…