How to list contents of a keystore using keytool

JAVA Keytool Description

keytool --help
Key and Certificate Management Tool

Commands:

 -certreq            Generates a certificate request
 -changealias        Changes an entry's alias
 -delete             Deletes an entry
 -exportcert         Exports certificate
 -genkeypair         Generates a key pair
 -genseckey          Generates a secret key
 -gencert            Generates certificate from a certificate request
 -importcert         Imports a certificate or a certificate chain
 -importpass         Imports a password
 -importkeystore     Imports one or all entries from another keystore
 -keypasswd          Changes the key password of an entry
 -list               Lists entries in a keystore
 -printcert          Prints the content of a certificate
 -printcertreq       Prints the content of a certificate request
 -printcrl           Prints the content of a CRL file
 -storepasswd        Changes the store password of a keystore
 -showinfo           Displays security-related information

Use "keytool -?, -h, or --help" for this help message
Use "keytool -command_name --help" for usage of command_name.
Use the -conf <url> option to specify a pre-configured options file.

Using Keytool output list of keystore

keytool -list -rfc \
-keystore ewallet.jks \
-storepass password \
-storetype JKS


Keystore type: JKS
Keystore provider: SUN

Your keystore contains 153 entries

Alias name: ac1
Creation date: Sep 7, 2022
Entry type: trustedCertEntry

-----BEGIN CERTIFICATE-----
MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE
AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw
CQYDVQQGEwJFUzAeFw0xMTA1MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQ
...
h1xA2syVP1XgNce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xF
d3+YJ5oyXSrjhO7FmGYvliAd3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2H
pPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3pEfbRD0tVNEYqi4Y7
-----END CERTIFICATE-----


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


Alias name: acm
Creation date: Sep 7, 2022
Entry type: trustedCertEntry

-----BEGIN CERTIFICATE-----
MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsx
CzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJ
WiBGTk1ULVJDTTAeFw0wODEwMjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJ
BgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBG
...
9kiABdcPUXmsEKvU7ANm5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wok
RqEIr9baRRmW1FMdW4R58MD3R++Lj8UGrp1MYp3/RgT408m2ECVAdf4WqslKYIYv
uu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
-----END CERTIFICATE-----

output alias key of keystore

keytool -list -rfc \
-alias example
-keystore ewallet.jks \
-storepass password \
-storetype JKS


Alias name: example
Creation date: Dec 8, 2022
Entry type: trustedCertEntry

-----BEGIN CERTIFICATE-----
MIICpTCCAY0CEECnOR0pqvZRXDFGAaUNFPQwDQYJKoZIhvcNAQELBQAwEDEOMAwG
A1UEAxMFUENBUlIwIBcNMjIxMTE1MDUzMjA2WhgPMjA1MjExMDcwNTMyMDZaMBAx
DjAMBgNVBAQTBVBDQVJSMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCZQEA
iw7Une6emN1TBwsjfpesAzTkna+4TZEf2/ufXiSZafBGdqxCPu8e+F/tt6nI6X6s
...
MD6g/KnYBRlqBP71gZ9KHfmiHotEYyBbTu37k8mJ4MQaOGg8Huf9HMULjI6wV/Nz
nIQcnAayLQWNXshj8QfIHiGWYYq3ZtoCTdPUyoHX0/7BaxnJDn6c3dN9BX3sy10z
/F2mFzEiWvoL3VG3xGJ2IQTTjHZV7QymoxlavYC1WszFDa52cx9ZbQ8zv40nZEyt
SER85Iv/7NE1
-----END CERTIFICATE-----

張貼留言

0 留言