0

I have this very simple example piece of code.

        String https_url = "https://www.somesite.ca";
        URL url;
        try {
            url = new URL(https_url);
            HttpsURLConnection con = (HttpsURLConnection) url.openConnection();

            System.out.println("****** Content of the URL ********");
            BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));

            String input;

            while ((input = br.readLine()) != null) {
                System.out.println(input);
            }
            br.close();


        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

it works fine on all the sites that i access except one. That one site just started failing with the exception

javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
    at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1979)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1086)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1301)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at com.unitnet.utils.intouch.TestSSL.testIt(TestSSL.java:42)
    at com.unitnet.utils.intouch.TestSSL.main(TestSSL.java:16)

I can make it work by running with jdk1.8 but that is really not an option. I really need to make it work with 1.7

Does anyone have any work arounds that can help me

thanks

randy
  • 1,685
  • 3
  • 34
  • 74

2 Answers2

0

Installing Java Cryptography Extension (JCE) Unlimited Strength solved the problem for me.

Source: here

Helder Antunes
  • 151
  • 2
  • 3
-1

the solution for the issue enables the TLS in JDK 1.7

jdk.tls.disabledAlgorithms= SSLv2Hello, SSLv3, TLSv1, TLSv1.1

in the file jre/lib/security/java.security on the server and After setting this, server only accepts the TLS1.2 connection and reject lower security protocol versions. This only works with Java 7 update 75 and later. for more

Community
  • 1
  • 1
HM.Rajjaz
  • 369
  • 1
  • 3
  • 17