Skip to content

Instantly share code, notes, and snippets.

@Mirochiu
Created March 31, 2023 02:53
Show Gist options
  • Save Mirochiu/c606e5d721b5f7b29b5773b32d2c028e to your computer and use it in GitHub Desktop.
Save Mirochiu/c606e5d721b5f7b29b5773b32d2c028e to your computer and use it in GitHub Desktop.
Use pk8 and x509.pem files in AOSP to generate the keystore file for Android Studio
#!/usr/bin/bash
# generate the keystore and show the result
storepassword="password"
outkeystore="mygen.keystore"
if [ $# -gt 0 ]; then
outkeystore="$1"
fi
if [ $# -gt 1 ]; then
storepassword="$2"
fi
if [ -f "$outkeystore" ] ; then
echo "found exist keystore: $outkeystore"
exit -1
fi
for keyname in "media" "releasekey" "shared" "platform"
do
echo $keyname
openssl pkcs8 -inform DER -nocrypt -in "$keyname.pk8" -out "$keyname.pem"
openssl pkcs12 -export -in "$keyname.x509.pem" -inkey "$keyname.pem" -out "$keyname.p12" -password pass:android -name "$keyname"
keytool -noprompt -importkeystore -deststorepass "$storepassword" -destkeystore "$outkeystore" -srckeystore "$keyname.p12" -srcstoretype PKCS12 -srcstorepass android
done
keytool -list -v -keystore "$outkeystore" -storepass "$storepassword" && echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment