首页>代码>java swing制作cer证书>/Cer/src/com/cer/test/CertUtil12.java
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日
最近浏览更多
暂无贡献等级
skook7  LV2 2023年9月7日
漫步的海星  LV4 2023年8月25日
杨豫川  LV12 2022年9月5日
拾壹may 11 2022年4月13日
暂无贡献等级
忧麦紫  LV18 2022年3月2日
sswert  LV2 2022年2月22日
ᯤʸᵒᵘ  LV1 2021年12月24日
尹恒yingying  LV18 2021年10月29日
annazhang  LV29 2021年7月24日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友