Showing posts with label HttpsURLConnection. Show all posts
Showing posts with label HttpsURLConnection. Show all posts

Wednesday, April 12, 2017

Setting TLS protocol version for HttpsURLConnection

SSLContext sc = SSLContext.getInstance("TLSv1.2"); //$NON-NLS-1$
sc.init(null, null, new java.security.SecureRandom());
HttpsURLConnection con = (HttpsURLConnection) httpsURL.openConnection();

con.setSSLSocketFactory(sc.getSocketFactory());

Other way would be setting VM arg to the Java.

-Dhttps.protocols=TLSv1.1,TLSv1.2