currently I have to use Java 7 (can't change it atm) and the default TLS Version is 1.0(?), so below 1.2. And now i have to use an REST Api which doesnt accept any TLS below TLSv1.2.
So my Solution for this was:
Before the REST Call:
System.setProperty("https.protocols", "TLSv1.2"); // Adding this System property only for this one function call. Has to be executed every time before
And Afterwards the GET Call itself:
...
URL url = new URL("https://test.com");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
...
Now my question is: Is there an alternative way to set the "https.protocols" property, so i dont have to set it in System?
Else im doubtful if this System property affects REST Calls from other classes, which has been executed at the same time.