EN
Bash - read *.p12 keystore info
3
points
In this short article, we would like to show how to read information about *.p12 keystore file using openssl
command.
Quick solution:
openssl pkcs12 -info -in /path/to/keystore_file.p12
Practical example
Run the following command:
openssl pkcs12 -info -in /path/to/keystore_file.p12
Where: /path/to/keystore_file.p12
should be changed into keystore file that we want to read.
Note: it is necessary to type password to read file (do it after
Enter Import Password:
message appeard).
Example output:
Enter Import Password:
MAC: sha1, Iteration 2048
MAC length: 20, salt length: 8
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048
Certificate bag
Bag Attributes
localKeyID: 45 12 22 14 8A F0 84 1F 9B FD 0A F4 B7 36 42 48 29 B3 7B 8E
subject=O = "CloudFlare, Inc.", OU = CloudFlare Origin CA, CN = CloudFlare Origin Certificate
issuer=C = US, O = "CloudFlare, Inc.", OU = CloudFlare Origin SSL Certificate Authority, L = San Francisco, ST = California
-----BEGIN CERTIFICATE-----
MIIEoDCCA4m9rA3Xr7ISvGhawOYO4wDQYJKoZIigAwIBAgIURCoe1iJ3hvcNAQEL
BQAwgYsxCzAJBgNVBAYTAlVTMRkwFwYDVQQKExBDbG91ZEZsYXJlLCBJbmMuMTQw
MgYDVQQLE2VydGlmaWNhdGUgQXVytDbG91ZEZsYXJlIE9yaWdpbiBTU0wgQ0aG9y
...
m6uDTG1iDPRzRpwlhyLG3xxV5Bm4rdb0a6lQyrMuG/WHGBlMVaw3csfM5KHrVwz/
W9nvxbAJfjIUNttPfJyZM+5l9lCMgOIhr2jhjRepgfyT2cljeab1Gn5dHocuG/Ig
MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECCsEIHead7OfBIIEyAESSwbs4mXU
9Vb3OehP7nSjyPrgb6jHM8w8CWnB06wuDAyZwGaWYe6JHDLJ
-----END CERTIFICATE-----
PKCS7 Data
Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2048
Bag Attributes
localKeyID: 45 12 22 14 8A F0 84 1F 9B FD 0A F4 B7 36 42 48 29 B3 7B 8E
Key Attributes: <No Attributes>
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIDwd95onkExYCAggA
kzl1Xx59Fm+84ByxwMz7JwLFy/LI5hvhTK85Id+Uff1lVAL+K6hAPGRJgPP0XCse
y2+butmmB1wDrTb7UMHqX6yCe4ODZARZmH7lEE0KK8DUF0duev9e8jGupFeX7x82
...
pWNvFzbRizAMv5bjP0YOL3yxpnIPDPrpyVD0wCpj/DEWEIB9nxyTdvbrH5crRitJ
41teOi4X9IyqQuB9YobIAkeeuwEtsUkcJ9Gm7x7Csi7oVeV+PFc2cKPbJcBQLixE
aXRNvMRMwEQYDVQQIEwpDYWxpZm9yb5MRYwFAYDVQQHEw1TYW4gRnJhbmNpc2mlh
E2565aVqP7g5gL9F/xXP/A==
-----END ENCRYPTED PRIVATE KEY-----