Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - export single key/alias from keystore

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!

like image 229
Oli Avatar asked Dec 19 '22 16:12

Oli


1 Answers

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

like image 94
Marcin Orlowski Avatar answered Jan 11 '23 19:01

Marcin Orlowski