獲取.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
- 如何獲取網站的HTTPS證書?網站HTTP
- 使用 Docker CertBot 獲取 SSL 證書Docker
- .pfx格式證書轉.key和.crt檔案
- 免費ssl證書獲取以及部署
- 如何驗證獲取S/MIME郵件安全證書
- Java 獲取PDF數字簽名證照資訊Java
- 獲取位置資訊
- C# 獲取PDF中的數字簽名證書C#
- 用Certbot 獲取和自動更新SSL證書
- Linux: 獲取硬碟的UUID資訊Linux硬碟UI
- 如何獲取SSL證書private key私鑰檔案
- docker獲取Let's Encrypt永久免費SSL證書Docker
- FDA ESG的數字簽名證書是什麼?怎麼獲取FDA ESG 數字證書?
- 阿里雲簡訊服務的使用-----獲取簡訊驗證碼阿里
- iphone 獲取地址的詳細資訊iPhone
- Oracle獲取所有表名資訊和獲取指定表名欄位資訊Oracle
- iOS獲取SIM卡資訊iOS
- 獲取AFP服務資訊
- Python下獲取視訊的旋轉角度資訊Python
- MFC中獲取程式自身的版本資訊
- 獲取地圖的資訊到input裡地圖
- 如何獲得PMP認證證書
- 大陸居民身份證、港澳臺居民居住證 Composer 包:驗證、獲取基本資訊以及生成假資料
- 【Python】獲取機器使用資訊Python
- ipmitool獲取伺服器資訊MIT伺服器
- ABL獲取XBL資訊記錄
- java爬取豆瓣書籍資訊Java
- 資訊爆炸時代,如何獲取優質資訊?
- 如何獲取 jenkins 中的憑證Jenkins
- Spring 中優雅的獲取泛型資訊Spring泛型
- iOS 獲取本機的裝置資訊UIDeviceiOSUIIDEdev
- js獲取裝置資訊的方法彙總JS
- Java獲取堆疊資訊的3種方法Java
- MySQL 如何獲取執行中的Queries資訊?MySql
- 獲取表的所有列及其型別資訊型別
- ExtJs獲取GridPanel選中行的詳細資訊JS