检索SSL服务器的认证路径
import java.io.IOException; /**from n o w j a v a . c o m - 时代Java**/ import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; public class Main { public void main(String[] argv) { try { // Create the client socket int port = 443; String hostname = "hostname"; SSLSocketFactory factory = HttpsURLConnection /* 来自 *时 代 J a v a - nowjava.com*/ .getDefaultSSLSocketFactory(); SSLSocket socket = (SSLSocket) factory.createSocket(hostname, port); // Connect to the server socket.startHandshake(); // Retrieve the server's certificate chain java.security.cert.Certificate[] serverCerts = socket.getSession() .getPeerCertificate