Retrieving the Certification Path of an SSL Server : SSL Socket « Security « Java Tutorial






import java.security.cert.Certificate;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;

public class Main {
  public static void main(String[] argv) throws Exception {
    int port = 443;
    String hostname = "hostname";
    SSLSocketFactory factory = HttpsURLConnection.getDefaultSSLSocketFactory();
    SSLSocket socket = (SSLSocket) factory.createSocket(hostname, port);

    socket.startHandshake();

    // Retrieve the server's certificate chain
    Certificate[] serverCerts = socket.getSession().getPeerCertificates();

    socket.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