您将必须 在 Java 1.8中 创建一个
SSLContext用于设置Protocoll的协议:
SSLContext sc = SSLContext.getInstance("TLSv1.2"); // Init the SSLContext with a TrustManager[] and SecureRandom() sc.init(null, trustCerts, new java.security.SecureRandom());在 Java 1.7中 :
SSLContext sc = SSLContext.getInstance("TLSv1"); // Init the SSLContext with a TrustManager[] and SecureRandom() sc.init(null, trustCerts, new java.security.SecureRandom());那么您只需将 SSLContext 设置为 HttpsURLConnection :
httpsCon.setSSLSocketFactory(sc.getSocketFactory());
这应该够了吧。



