0

I need to Enable a TLS 1.2 connection in IBM Java 1.6[SR16 FP60]. I tried establishing the connection by

 public static void TLS() throws NoSuchAlgorithmException, KeyManagementException, IOException{

    System.setProperty("https.protocols", "TLSv1.2");

URL url = new URL("https://jsonplaceholder.typicode.com/posts");



    String XML = "<Test></test>"
     SSLContext ssl = SSLContext.getInstance("TLSv1.2"); 

    // ctx.init(null, null, null);

     ssl.init(null, null, null);
     SSLContext.setDefault(ssl);

     HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();


     connection.setSSLSocketFactory(ssl.getSocketFactory());
     connection.setRequestMethod("POST");
     connection.setRequestProperty("Content-Type", "application/xml");
     connection.setDoOutput(true);
        OutputStream os = connection.getOutputStream();
        os.write(XML.getBytes());
        os.flush();
        os.close();
    System.out.println(">>>Connection certificate"+connection.getServerCertificates());
    System.out.println(">>>Connection"+connection.getContent());
    int responseCode = connection.getResponseCode();


    System.out.println("POST Response Code :  " + responseCode);
    System.out.println("POST Response Message : " + connection.getResponseMessage());
    if (responseCode == HttpsURLConnection.HTTP_OK) { //success
        BufferedReader in = new BufferedReader(new InputStreamReader(
            connection.getInputStream()));
        String inputLine;
        StringBuffer response = new StringBuffer();
        while ((inputLine = in .readLine()) != null) {
            response.append(inputLine);
        } in .close();

        System.out.println(response.toString());}

 }

While establishing the connection it's throwing an error

Received Fatal alert : handshake_failure

Please advise us the resolve this issue.

Debugger
  • 306
  • 3
  • 19

1 Answers1

2

I guess you are using WebSphere 6? You have to upgrade to 7.0.0.23, 8.0.0.3 or 8.5.

See https://developer.ibm.com/answers/questions/206952/how-do-i-configure-websphere-application-server-ss.html

Nic3500
  • 5,007
  • 10
  • 26
  • 33
  • Thanks @nic. I am using websphere 7.0 and Java Java 1.6[SR16 FP60]. I think TLS 1.2 support in IBM java 1.6 https://stackoverflow.com/questions/33364100/how-to-use-tls-1-2-in-java-6 Please advise – Debugger Oct 14 '18 at 16:30
  • https://developer.ibm.com/answers/questions/351300/is-there-support-for-tls-12-for-bpm-using-java-6-o/ – Debugger Oct 14 '18 at 16:36