I'm trying to call a REST API for some end point URL, it was running fine for the URL of java.net and after executing the same. But on some machines it failed for some SSLException so the code was modified like this:
HttpsURLConnection connection = (HttpsURLConnection) new URL( url ).openConnection()
SSLContext sc = SSLContext.getInstance("TLSv1.2")
sc.init(null, null, new SecureRandom())
connection.setSSLSocketFactory(sc.getSocketFactory())
connection.setRequestProperty("charset", "utf-8")
InputStream input = connection.getInputStream()
InputStreamReader reader = new InputStreamReader(input, "utf-8")
BufferedReader buffer = new BufferedReader(reader)
buffer.lines().collect(Collectors.joining("\n"))
Now again it's working fine, if I'm not wrong it is for secured communication, but then why was the SSLexception on Linux env and not on Windows, and SSLContext.getInstance("TLSv1.2")
will this work on all environments, why not TLSV1.1 does all environment have 1.2 or latest version by default, how do I make sure that it will run on all the environments?