Skip to content

Instantly share code, notes, and snippets.

@toufik-airane
Last active January 14, 2020 02:58
Show Gist options
  • Save toufik-airane/0d8e8dbed85cb023a4fc to your computer and use it in GitHub Desktop.
Save toufik-airane/0d8e8dbed85cb023a4fc to your computer and use it in GitHub Desktop.
Merge .pk8 && .pem into .keystore ~ CyanogenMod APK System Privilege
#!/bin/sh
####
# Example :
# ./gen_keystore platform.x509.pem platform.pk8 android platform system.cyanogenmod.keystore
####
echo "$0 <.pem file> <.pk8 file> <password> <alias> <output>"
if test $# -ne 5; then
echo "[Error] Invalid arguments"
exit 1
fi
tmpdir=`mktemp -d -q /tmp/gen_keystore.XXXXXXXX`
openssl pkcs8 -inform DER -nocrypt -in $2 -out ${tmpdir}/key
openssl pkcs12 -export -in $1 -inkey ${tmpdir}/key -out ${tmpdir}/p12 -password pass:$3 -name $4
openssl x509 -noout -fingerprint -in $1
keytool -importkeystore -deststorepass $3 -destkeystore $5 -srckeystore ${tmpdir}/p12 -srcstoretype PKCS12 -srcstorepass $3
rm -r ${tmpdir}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment