package com.xgh.x509.cert.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.util.Date;
import junit.framework.TestCase;
public class CertManager extends TestCase{
/***
* 读取*.cer公钥证书文件, 获取公钥证书信息
* @author xgh
*/
public void testReadX509CerFile() throws Exception{
try {
// 读取证书文件
File file = new File("src/GYGSCB2100000500.cer");
InputStream inStream = new FileInputStream(file);
// 创建X509工厂类
CertificateFactory cf = CertificateFactory.getInstance("X.509");
//CertificateFactory cf = CertificateFactory.getInstance("X509");
// 创建证书对象
X509Certificate oCert = (X509Certificate) cf
.generateCertificate(inStream);
inStream.close();
SimpleDateFormat dateformat = new SimpleDateFormat(
读取*.cer公钥证书文件, 获取公钥证书信息
最新推荐文章于 2024-07-13 03:06:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)