Wednesday, 21 January 2015

Sign Android APK with iOS Key

I was given what looked like an iOS signing key for our nice new Android app. Based on the instructions they asked for I was expecting a jks keystore file as created by keytool. Before I sent them a reply saying I could not use the iOS key, I figured I would try to make it work first.

The Magic


First we need to convert the key into something that keytool can import into our keystore. It turns out that keytool can import a private key by using a work around that uses two different features: using a PKCS12 formatted key as a keystore and merging keystores.

A Quick Read


# Convert PEM to PKCS12 format.
openssl pkcs12 -export -out certificate.pfx -in certificate.pem

# Import into our keystore
keytool -importkeystore -destkeystore my-keystore.jks -srckeystore certificate.pfx -srcstoretype PKCS12 -alias 1

# The openssl export does not preserve the alias name, it uses "1", so rename it.
keytool -changealias -alias "1" -destalias "my_signing_key" -keystore my-keystore.jks

No comments:

Post a Comment