public class SslSocketClient { public static void main(String[] args) throws Exception { SSLSocketFactory f = (SSLSocketFactory) SSLSocketFactory.getDefault(); SSLSocket socket = (SSLSocket) f.createSocket("localhost", 9000); socket.setEnabledProtocols(new String[] { "SSLv3" }); printSocketInfo(socket); socket.startHandshake(); PrintWriter writer = new PrintWriter(socket.getOutputStream(), true); BufferedReader reader = new BufferedReader(new InputStreamReader( socket.getInputStream())); String line = "JAVA CLIENT REQUEST"; writer.println(line); while ((line = reader.readLine()) != null) { System.out.println("Received: [" + line + "]"); break; } writer.close(); reader.close(); socket.close(); } private static void printSocketInfo(SSLSocket s) { System.out.println("Socket class: " + s.getClass()); System.out.println(" Remote address = " + s.getInetAddress().toString()); System.out.println(" Remote port = " + s.getPort()); System.out.println(" Local socket address = " + s.getLocalSocketAddress().toString()); System.out.println(" Local address = " + s.getLocalAddress().toString()); System.out.println(" Local port = " + s.getLocalPort()); System.out.println(" Need client authentication = " + s.getNeedClientAuth()); SSLSession ss = s.getSession(); System.out.println(" Cipher suite = " + ss.getCipherSuite()); System.out.println(" Protocol = " + ss.getProtocol()); } }