[Mac] 使用 keytool 指令檢視 Java JKS 檔案裡的內容

[Mac] 使用 keytool 指令檢視 Java JKS 檔案裡的內容

今天拿到一個 Java 在用的 JKS 檔案,

不過平常我不會寫 Java,要怎麼確認這個 JKS 檔案的內容呢?

 

查了一下,假設有安裝 JDK 或 OpenJDK 的話,

那應該會有 keytool 這個工具可以用~

跑下面的指令,就可以列出 JKS 檔案裡面的東西:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ keytool -list -v -keystore test.jks
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 1 entry
Alias name: ca
Creation date: Oct 9, 2024
Entry type: trustedCertEntry
Owner: CN=Root CA, O=TestCompany, C=US
Issuer: CN=Root CA, O=TestCompany, C=US
Serial number: 256b34495e72af99561ea82ca4128abc
Valid from: Wed Sep 11 21:13:57 CST 2024 until: Sun May 29 21:13:57 CST 2044
Certificate fingerprints:
SHA1: 5A:79:C7:29:20:41:21:05:5F:71:20:10:4B:89:1B:D3:4B:4A:9A:1A
SHA256: 80:B3:A8:2B:AE:F8:6F:F0:42:A3:20:5C:DE:1C:EE:91:21:F4:C4:DC:D5:F7:7E:8B:AF:16:A1:90:8F:0C:A3:1F
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 4096-bit RSA key
Version: 3
Extensions:
#1: ObjectId: 2.5.29.19 Criticality=true
BasicConstraints:[
CA:true
PathLen: no limit
]
#2: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
DigitalSignature
Key_Encipherment
Key_CertSign
]
#3: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: D2 45 4E DA F1 47 3B 63 B7 4F A0 72 F6 7C BA 53 .EN..G;c.O.r...S
0010: 39 73 21 58 9s!X
]
]
*******************************************
*******************************************
$ keytool -list -v -keystore test.jks Enter keystore password: Keystore type: JKS Keystore provider: SUN Your keystore contains 1 entry Alias name: ca Creation date: Oct 9, 2024 Entry type: trustedCertEntry Owner: CN=Root CA, O=TestCompany, C=US Issuer: CN=Root CA, O=TestCompany, C=US Serial number: 256b34495e72af99561ea82ca4128abc Valid from: Wed Sep 11 21:13:57 CST 2024 until: Sun May 29 21:13:57 CST 2044 Certificate fingerprints: SHA1: 5A:79:C7:29:20:41:21:05:5F:71:20:10:4B:89:1B:D3:4B:4A:9A:1A SHA256: 80:B3:A8:2B:AE:F8:6F:F0:42:A3:20:5C:DE:1C:EE:91:21:F4:C4:DC:D5:F7:7E:8B:AF:16:A1:90:8F:0C:A3:1F Signature algorithm name: SHA256withRSA Subject Public Key Algorithm: 4096-bit RSA key Version: 3 Extensions: #1: ObjectId: 2.5.29.19 Criticality=true BasicConstraints:[ CA:true PathLen: no limit ] #2: ObjectId: 2.5.29.15 Criticality=true KeyUsage [ DigitalSignature Key_Encipherment Key_CertSign ] #3: ObjectId: 2.5.29.14 Criticality=false SubjectKeyIdentifier [ KeyIdentifier [ 0000: D2 45 4E DA F1 47 3B 63 B7 4F A0 72 F6 7C BA 53 .EN..G;c.O.r...S 0010: 39 73 21 58 9s!X ] ] ******************************************* *******************************************
$ keytool -list -v -keystore test.jks

Enter keystore password:
Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: ca
Creation date: Oct 9, 2024
Entry type: trustedCertEntry

Owner: CN=Root CA, O=TestCompany, C=US
Issuer: CN=Root CA, O=TestCompany, C=US
Serial number: 256b34495e72af99561ea82ca4128abc
Valid from: Wed Sep 11 21:13:57 CST 2024 until: Sun May 29 21:13:57 CST 2044
Certificate fingerprints:
     SHA1: 5A:79:C7:29:20:41:21:05:5F:71:20:10:4B:89:1B:D3:4B:4A:9A:1A
     SHA256: 80:B3:A8:2B:AE:F8:6F:F0:42:A3:20:5C:DE:1C:EE:91:21:F4:C4:DC:D5:F7:7E:8B:AF:16:A1:90:8F:0C:A3:1F
Signature algorithm name: SHA256withRSA
Subject Public Key Algorithm: 4096-bit RSA key
Version: 3

Extensions:

#1: ObjectId: 2.5.29.19 Criticality=true
BasicConstraints:[
  CA:true
  PathLen: no limit
]

#2: ObjectId: 2.5.29.15 Criticality=true
KeyUsage [
  DigitalSignature
  Key_Encipherment
  Key_CertSign
]

#3: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: D2 45 4E DA F1 47 3B 63   B7 4F A0 72 F6 7C BA 53  .EN..G;c.O.r...S
0010: 39 73 21 58                                        9s!X
]
]



*******************************************
*******************************************

 

(本頁面已被瀏覽過 37 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料