4
When making an https request I have the following Exception:
javax.net.ssl.Sslexception: Unsupported record version Sslv2hello
public static void main(String[] args) throws Exception {
URL url = new URL("URL");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
try {
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type","application/json; charset=UTF-8");
conn.setDoOutput(true);
conn.getResponseCode();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
System.out.println(e);
}
conn.disconnect();
}
The Exception happens in
} catch (Ioexception and) {
while trying to make
Conn.getResponseCode();
The problem is the certificate, the code is fine as said. Thanks for the test. I tested again with a different https and it worked. Thanks
– Micael Costa