Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I generate an Android Keystore from a key.pk8 and certificate.pem?

So today I finally update my SDK to 22.0.0 however this creates an error in the AndroidManifest.xml for android:debuggable="false" which means I can no longer externally sign and zipalign my own apks.

I have been signing using my own key.pk8 and certificate.pem, however eclipse ADT requires a keystore.

Does anyone know a way to either build a keystore using my already generated key or find some way around this?

like image 211
Sam Shute Avatar asked Mar 06 '14 01:03

Sam Shute


People also ask

How do I export the certificate for the upload key to PEM format?

You can export the certificate of your new app signature from . jks file in two way: Via CMD/PowerShell or Terminal : keytool -export -rfc -alias upload -file upload_certificate. pem -keystore keystore.

How do I get APK keystore?

In the menu bar, click Build > Generate Signed Bundle/APK. In the Generate Signed Bundle or APK dialog, select Android App Bundle or APK and click Next. Below the field for Key store path, click Create new. On the New Key Store window, provide the following information for your keystore and key, as shown in figure 2.

Can Android use same keystore?

So yes, you can use the same keystore to sign multiple apks, without a problem. You can also use the same alias (each alias is a certificate) to sign multiple apks, and it will work. It has security implications, however.


1 Answers

Ok, So I eventually managed to solve the problem.

I downloaded openssl for windows from here

Keytool can be found at E:\Program Files\Java\jdk1.7.0_17\bin

Then using keytool and openssl managed to build the key.pk8 and certificate.pem into a keystore entry

openssl pkcs8 -inform DER -nocrypt -in key.pk8 -out key.pem

openssl pkcs12 -export -in certificate.pem -inkey key.pem -out platform.p12 -password pass:android -name mykey

keytool -importkeystore -deststorepass password -destkeystore .keystore -srckeystore platform.p12 -srcstoretype PKCS12 -srcstorepass android

keytool -list -v -keystore .keystore

The last step is just to verify that the key has been added to the keystore.

like image 100
Sam Shute Avatar answered Oct 18 '22 19:10

Sam Shute