How Do I Know When the “Handshake” Is Over?

How Do I Know When the “Handshake” Is Over?

The following code is a JSSE client application that uses the HandshakeCompletedListener interface to find out when a handshake is over.

import*;import*;import*;import*;class contact_server implements HandshakeCompletedListener{Socket SSLsoclu=null;          //client socketPrintWriter out=null;          //out streamBufferedReader in=null;        //in streamInputStreamReader ISR=null;String intrare=null;String iesire=null;BufferedReader message=null;  public contact_server(){}void send_message(){try{   SocketFactory SSLfabrica=SSLSocketFactory.getDefault();    SSLsoclu=SSLfabrica.createSocket("",443);         ((SSLSocket)SSLsoclu).addHandshakeCompletedListener(this);  ((SSLSocket)SSLsoclu).startHandshake();         }catch(IOException e)       {       System.out.println("Error 1:"+e.getMessage());       System.exit(1);       }        try{      out=new PrintWriter(SSLsoclu.getOutputStream(),true);      ISR=new InputStreamReader(SSLsoclu.getInputStream());         in=new BufferedReader(ISR);                      while((intrare=in.readLine())!=null)       {           System.out.println("Server "+intrare);       message=new BufferedReader(new InputStreamReader(;       System.out.flush();       System.out.print("Send:");       iesire=message.readLine();       if (iesire!=null)out.println(iesire);                                else break;       }      System.out.println("Connection canceled!!!");      out.close();      in.close();      message.close();      SSLsoclu.close();            }catch(IOException e)           {           System.out.println("Error 2:"+e.getMessage());           System.exit(1);           }  }  public void handshakeCompleted(HandshakeCompletedEvent e)     {     System.out.println(""Handshake" over!");     System.out.println(e.getCipherSuite());     }  }public class SSLClientSide{public static void main(String[] args){//put here your one keystore - this is just an exampleSystem.setProperty("","SSLcert");System.setProperty("","e1002qa2");    contact_server t=new contact_server();    t.send_message();    }}
Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of