Creating an SSL Client Socket : SSLServerSocket « Network « Java Tutorial






import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;

public class Main {
  public static void main(String[] argv) throws Exception {
    int port = 443;
    String hostname = "hostname";
    SocketFactory socketFactory = SSLSocketFactory.getDefault();
    Socket socket = socketFactory.createSocket(hostname, port);


    InputStream in = socket.getInputStream();
    OutputStream out = socket.getOutputStream();

    // Read from in and write to out...

    in.close();
    out.close();
  }
}








19.16.SSLServerSocket
19.16.1.SSL Server Demo
19.16.2.Creating an SSL Client Socket
19.16.3.Creating an SSL Server Socket
19.16.4.Secure Communication with JSSE