0
votes

i get a "Exception in thread "main" javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure" for the code below. Does anybody know how to fix it?

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;

public class Test {
static {
    System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2,SSLv3,SSLv2Hello");
    HostnameVerifier hv = new HostnameVerifier() {
        public boolean verify(String urlHostName, SSLSession session) {
            return true;
        }
    };
    HttpsURLConnection.setDefaultHostnameVerifier(hv);
}

public static void main(String[] args) throws MalformedURLException, IOException {
    HttpURLConnection con = (HttpsURLConnection) new URL("https://www.sureworks.de").openConnection();
    con.connect();
}
}
1
What's the output if you run the JVM with -Djavax.net.debug=ssl?Andrew Henle
What version of Java are you running your test with? Testing the site using SSLLabs indicates that SNI support is needed to connect to the site. That would require Java 1.7 or later.user3745362

1 Answers