獲取.crt證書的資訊
獲取.crt證照的資訊
生成後的.crt檔案的位置 :==cerPath==要能拿到生成的RootCa.pfx檔案
測試的程式碼如下:
public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException, UnrecoverableKeyException, CertificateException, SignatureException, IOException {
try {
getX509CerCate("D:\\file\\");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//CerUtil util = new CerUtil();
//util.createRootCA();
//util.signCert("dev1","hijklm","zxcvbn");
}
public static X509Certificate getX509CerCate(String cerPath) throws Exception {
KeyStore ks = KeyStore.getInstance("pkcs12");
FileInputStream ksfis = new FileInputStream(cerPath + "RootCa.pfx");
char[] storePwd = "12345678".toCharArray();
char[] keyPwd = "abcd1234".toCharArray();
ks.load(ksfis, storePwd);
ksfis.close();
PrivateKey privK = (PrivateKey) ks.getKey("RootCA", keyPwd);
X509Certificate certificate = (X509Certificate) ks
.getCertificate("RootCA");
byte certbytes[] = certificate.getEncoded();
X509CertImpl x509certimpl = new X509CertImpl(certbytes);
X509CertInfo x509certinfo = (X509CertInfo) x509certimpl
.get("x509.info");
System.out.println("讀取Crt證照資訊...");
System.out.println(x509certinfo);
System.out.println("x509Certificate_SerialNumber_序列號___:"+x509certimpl.getSerialNumber());
System.out.println("x509Certificate_getIssuerDN_釋出方標識名___:"+x509certimpl.getIssuerDN());
System.out.println("x509Certificate_getSubjectDN_主體標識___:"+x509certimpl.getSubjectDN());
System.out.println("x509Certificate_getSigAlgOID_證照演算法OID字串___:"+x509certimpl.getSigAlgOID());
System.out.println("x509Certificate_getNotBefore_證照有效期___:"+x509certimpl.getNotAfter());
System.out.println("x509Certificate_getSigAlgName_簽名演算法___:"+x509certimpl.getSigAlgName());
System.out.println("x509Certificate_getVersion_版本號___:"+x509certimpl.getVersion());
System.out.println("x509Certificate_getPublicKey_公鑰___:"+x509certimpl.getPublicKey());
return x509certimpl;
}
**
列印的資訊:
**
讀取Crt證照資訊…
[
Version: V3
Subject: CN=RootCA, OU=SHEPC, O=IOT, L=SHANGHAI, ST=SHANGHAI, C=CN
Signature Algorithm: MD5withRSA, OID = 1.2.840.113549.1.1.4
Key: Sun RSA public key, 1024 bits
modulus: 147005897895154579158611362635705015526343567540179810787720962647813476263007438703260428614713959050489969320407032188354154864458173391924174572670760787020376059450959590201769673352310306436317737681841023634858859421706688264107997615904562148395975950346111044420745647553726796261007466030261120823247
public exponent: 65537
Validity: [From: Wed Sep 23 11:05:07 CST 2020,
To: Sat Sep 21 11:05:07 CST 2030]
Issuer: CN=RootCA, OU=SHEPC, O=IOT, L=SHANGHAI, ST=SHANGHAI, C=CN
SerialNumber: [ 5811e900]
]
x509Certificate_SerialNumber_序列號___:1477568768
x509Certificate_getIssuerDN_釋出方標識名___:CN=RootCA, OU=SHEPC, O=IOT, L=SHANGHAI, ST=SHANGHAI, C=CN
x509Certificate_getSubjectDN_主體標識___:CN=RootCA, OU=SHEPC, O=IOT, L=SHANGHAI, ST=SHANGHAI, C=CN
x509Certificate_getSigAlgOID_證照演算法OID字串___:1.2.840.113549.1.1.4
x509Certificate_getNotBefore_證照有效期___:Sat Sep 21 11:05:07 CST 2030
x509Certificate_getSigAlgName_簽名演算法___:MD5withRSA
x509Certificate_getVersion_版本號___:3
x509Certificate_getPublicKey_公鑰___:Sun RSA public key, 1024 bits
modulus: 147005897895154579158611362635705015526343567540179810787720962647813476263007438703260428614713959050489969320407032188354154864458173391924174572670760787020376059450959590201769673352310306436317737681841023634858859421706688264107997615904562148395975950346111044420745647553726796261007466030261120823247
public exponent: 65537
相關文章
- google books api 獲取圖書資訊GoAPI
- 使用 Docker CertBot 獲取 SSL 證書Docker
- 如何獲取網站的HTTPS證書?網站HTTP
- 免費ssl證書獲取以及部署
- android如何獲取證書籤名?Android
- 獲取公鑰證書的DN(Distinguished Name)NGUI
- 如何驗證獲取S/MIME郵件安全證書
- C# 獲取PDF中的數字簽名證書C#
- 用Certbot 獲取和自動更新SSL證書
- Java 獲取PDF數字簽名證照資訊Java
- 如何獲取SSL證書private key私鑰檔案
- docker獲取Let's Encrypt永久免費SSL證書Docker
- FDA ESG的數字簽名證書是什麼?怎麼獲取FDA ESG 數字證書?
- 如何獲得PMP認證證書
- mac獲取cpu資訊Mac
- 獲取資訊版本1
- iphone 獲取地址的詳細資訊iPhone
- 獲取網路卡的相關資訊
- Oracle獲取所有表名資訊和獲取指定表名欄位資訊Oracle
- C# url資訊獲取C#
- 常用OS獲取資訊命令
- GetDiskSerial DLL獲取硬碟資訊硬碟
- 前端獲取驗證碼前端
- 根據身份證號碼獲取性別資訊程式碼例項
- MFC中獲取程式自身的版本資訊
- 獲取地圖的資訊到input裡地圖
- Linux: 獲取硬碟的UUID資訊Linux硬碟UI
- 獲取當前會話資訊的方法會話
- AWR 中 top sql 的資訊獲取 - 分析SQL
- iOS獲取裝置資訊的常用方法iOS
- Android使用命令獲取sha1證書指紋資料的方法Android
- Request.ServerVariables,C#獲取伺服器資訊,C#獲取訪問資訊ServerC#伺服器
- java爬取豆瓣書籍資訊Java
- PHP根據身份證號碼,獲取性別、獲取生日、計算年齡、獲取地址、獲取生肖、獲取星座、以及判斷是否是身份證號(方法教程)PHP
- ipmitool獲取伺服器資訊MIT伺服器
- iOS獲取SIM卡資訊iOS
- Android系統資訊獲取Android
- javascript 獲取瀏覽器資訊JavaScript瀏覽器