Android - export single key/alias from keystore
Asked Answered
O

1

5

I have a single keystore (JKS) with a lot of key entries / aliases for different apps in it. Now one app will be moved to another developer and I want to export / extract the single key / alias for him.

> keytool.exe -list -keystore Keystorefile

Keystore-type: JKS
Keystore-provider: SUN

Keystore contains 6 entries

Appname1, 01.07.20XX, PrivateKeyEntry,
certificate-Fingerprint (SHA1): AA:BB:CC:DD:EE:FF:GG:HH:II:JJ:KK:LL:MM:NN:OO:PP:Q
Q:RR:SS:TT
Appname2, 29.05.20XX, PrivateKeyEntry,
certificate-Fingerprint (SHA1): AA:BB:CC:DD:EE:FF:GG:HH:II:JJ:KK:LL:MM:NN:OO:PP:Q
Q:RR:SS:TT
Appname3, 30.09.20XX, PrivateKeyEntry,
certificate-Fingerprint (SHA1): AA:BB:CC:DD:EE:FF:GG:HH:II:JJ:KK:LL:MM:NN:OO:PP:Q
Q:RR:SS:TT
Appname4, 18.02.20XX, PrivateKeyEntry,
certificate-Fingerprint (SHA1): AA:BB:CC:DD:EE:FF:GG:HH:II:JJ:KK:LL:MM:NN:OO:PP:Q
Q:RR:SS:TT
Appname5, 09.08.20XX, PrivateKeyEntry,
certificate-Fingerprint (SHA1): AA:BB:CC:DD:EE:FF:GG:HH:II:JJ:KK:LL:MM:NN:OO:PP:Q
Q:RR:SS:TT
Appname6, 11.02.20XX, PrivateKeyEntry,
certificate-Fingerprint (SHA1): AA:BB:CC:DD:EE:FF:GG:HH:II:JJ:KK:LL:MM:NN:OO:PP:Q
Q:RR:SS:TT

This is the output of my Keystore, now I want to export only the Key for Appname2. That this can be imported in another Keystore if possible.

Thanks!

Ovarian answered 1/6, 2016 at 7:36 Comment(0)
A
14

This is bit less strigforward than exporting certificates (which can be exported with -exportcert) as you need to use -importkeystore and create new keystore with the key you want to "export", i.e.

keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -deststoretype PKCS12 -srcalias ALIAS -deststorepass PASS -destkeypass PASS

Alternatively you can just copy your current keystore file and then remove all keys from it but the one you want to export.

You can also check Keystore Explorer tool

Armillary answered 1/6, 2016 at 8:1 Comment(2)
What about using Android Studio?Alexei
That keystore explorer tool is perfect. It really trivialises this sort of thing.Dissever

© 2022 - 2024 — McMap. All rights reserved.