1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
public void () { try { URL url = new URL("https://www.baidu.com"); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.connect(); Certificate[] certs = conn.getServerCertificates(); X509Certificate cert = (X509Certificate) certs[0]; System.out.println("序号:" + cert.getSerialNumber()); System.out.println("颁发给:" + cert.getSubjectDN().getName()); System.out.println("颁发者:" + cert.getIssuerDN().getName()); System.out.println("起始:" + cert.getNotBefore()); System.out.println("过期:" + cert.getNotAfter()); System.out.println("算法:" + cert.getSigAlgName()); System.out.println("指纹:" + getThumbPrint(cert)); conn.disconnect(); } catch (Exception e) { e.printStackTrace(); }
}
|
近期评论