You will have to create an SSLContext to set the Protocoll:
then you just have to set the SSLContext to the HttpsURLConnection:
httpsCon.setSSLSocketFactory(sc.getSocketFactory());
then you just have to set the SSLContext to the HttpsURLConnection:
httpsCon.setSSLSocketFactory(sc.getSocketFactory());
package com.pkm; import java.net.URL; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; public class TLSRequest { public static void main(String[] args) throws Exception { HttpsURLConnection connection = (HttpsURLConnection) new URL("https://pritom.com").openConnection(); // TLSv1 | TLSv1.1 | TLSv1.2 SSLContext sc = SSLContext.getInstance("TLSv1"); sc.init(null, null, new java.security.SecureRandom()); connection.setSSLSocketFactory(sc.getSocketFactory()); } }