Https Socket Client : HTTPS « Security « Java Tutorial






import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

import javax.net.ssl.SSLSocketFactory;

public class MainClass {
  public static void main(String args[]) throws Exception {

    System.setProperty("javax.net.ssl.trustStore", "clienttrust");
    SSLSocketFactory ssf = (SSLSocketFactory) SSLSocketFactory.getDefault();
    Socket s = ssf.createSocket("127.0.0.1", 8888);

    OutputStream outs = s.getOutputStream();
    PrintStream out = new PrintStream(outs);
    InputStream ins = s.getInputStream();
    BufferedReader in = new BufferedReader(new InputStreamReader(ins));

    out.println("Hi,How are u!");
    out.println("");
    String line = null;
    while ((line = in.readLine()) != null) {
      System.out.println(line);
    }

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








36.45.HTTPS
36.45.1.HTTPS Client
36.45.2.HTTPS Server
36.45.3.HTTPS Server using the JSSE
36.45.4.Certification for HTTPS
36.45.5.HTTPS Server Proxy
36.45.6.Use HTTPS Server to transfer File
36.45.7.HTTPS Server Authentication
36.45.8.Https Socket Client
36.45.9.Disabling Certificate Validation in an HTTPS Connection