package com.cer.test; import java.io.FileInputStream; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; /** * @author God * 随便找一个.cer文件读取即可 */ public class CertUtil12 { /** * @author God * @cerPath Java读取Cer证书信息 * @throws Exception * @return X509Cer对象 */ public static X509Certificate getX509CerCate(String cerPath) throws Exception { X509Certificate x509Certificate = null; CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); FileInputStream fileInputStream = new FileInputStream(cerPath); x509Certificate = (X509Certificate) certificateFactory.generateCertificate(fileInputStream); fileInputStream.close(); System.out.println("读取Cer证书信息..."); System.out.println("x509Certificate_SerialNumber_序列号___:"+x509Certificate.getSerialNumber()); System.out.println("版本号:"+x509Certificate.getVersion()); System.out.println("序列号:"+x509Certificate.getSerialNumber().toString(16)); System.out.println("主体名:"+x509Certificate.getSubjectDN()); System.out.println("签发者:"+x509Certificate.getIssuerDN()); System.out.println("有效期:"+x509Certificate.getNotBefore()); System.out.println("截止日期:"+x509Certificate.getNotAfter()); System.out.println("签名算法:"+x509Certificate.getSigAlgName()); System.out.println("x509Certificate_getIssuerDN_发布方标识名___:"+x509Certificate.getIssuerDN()); System.out.println("x509Certificate_getSubjectDN_主体标识___:"+x509Certificate.getSubjectDN()); System.out.println("x509Certificate_getSigAlgOID_证书算法OID字符串___:"+x509Certificate.getSigAlgOID()); System.out.println("x509Certificate_getNotBefore_证书有效期___:"+x509Certificate.getNotAfter()); System.out.println("x509Certificate_getSigAlgName_签名算法___:"+x509Certificate.getSigAlgName()); System.out.println("x509Certificate_getVersion_版本号___:"+x509Certificate.getVersion()); System.out.println("x509Certificate_getPublicKey_公钥___:"+x509Certificate.getPublicKey()); return x509Certificate; } }

尹恒yingying LV18
2021年10月29日
1401170562 LV1
2020年4月24日
zjhylove LV1
2020年4月13日
ssh0 LV11
2020年3月26日
francochan LV6
2019年8月5日
2668869965 LV1
2019年7月31日
闫繁宇 LV9
2019年1月18日
best2018 LV46
2018年11月15日
走你個魯 LV21
2018年7月19日
Weipeng_ LV14
2018年6月22日