SSL Socket Client : SSL Socket « Security « Java Tutorial






import java.io.*;
import java.net.*;
import javax.net.ssl.*;

public class MainClass {

  private static final String HOST = "localhost";

  private static final int PORT = 8080;

  public static void main(String[] args) throws Exception {
    SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault();
    Socket s = sf.createSocket(HOST, PORT);
    OutputStream out = s.getOutputStream();
    out.write("\nConnection established.\n\n".getBytes());
    out.flush();
    int theCharacter = 0;
    theCharacter = System.in.read();
    while (theCharacter != '~') // The '~' is an escape character to exit
    {
      out.write(theCharacter);
      out.flush();
      theCharacter = System.in.read();
    }

    out.close();
    s.close();
  }
}








36.44.SSL Socket
36.44.1.Use SSLServerSocketFactory to create a SSL Server
36.44.2.SSL Server Session
36.44.3.SSL Client Session
36.44.4.Send html(gif) file through SSLSocket
36.44.5.SSL Client Demo
36.44.6.SSL Client with javax.net.ssl.trustStore setting
36.44.7.SSL Socket Server
36.44.8.SSL Socket Client
36.44.9.Sun SSL Socket Client
36.44.10.Sun SSL Socket Server
36.44.11.SSL Simple Client
36.44.12.SSL Simple Server
36.44.13.SSL Client Verifier
36.44.14.SSLContext and Key manager
36.44.15.SSL Server with KeyStore and Key Store Password setting
36.44.16.Get peer certificate from SSL session
36.44.17.Retrieving the Certification Path of an SSL Server