Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Signing apk with .p12

I am going to update my client's app which is available on Google PlayStore. And I have only a .p12 file with password, not .keystore file.

I am wondering if it's possible to publish the updated version to Google PlayStore.

Sorry for basic question. I am so confused with that. Thank you in advance for your assistance.

like image 513
Joey Avatar asked Nov 07 '13 06:11

Joey


People also ask

What is signed APK in Android Studio?

In Android Studio, you can configure your project to sign the release version of your app automatically during the build process by creating a signing configuration and assigning it to your release build type. A signing configuration consists of a keystore location, keystore password, key alias, and key password.

How do I download an app signing certificate?

Here's where to find the certificate: Open Play Console and go to the Play App Signing page (Release > Setup > App integrity). Scroll to the “App signing key certificate” section and copy the fingerprints (MD5, SHA-1, and SHA-256) of your app signing certificate.

What is the use of keystore in app signing?

As a security measure, Android requires that apps be signed in order to be installed. Signing an app first requires creating keystores. A keystore is a storage mechanism for security certificates. A public key certificate is used to sign an APK before deployment to services like the Google Play Store.


3 Answers

You can just convert your p12 file to jks:

Create an empty JKS store

keytool -genkey -alias anyname -keystore yourcertificate.jks
keytool -delete -alias anyname -keystore yourcertificate.jks

Import yourcertificate.p12 into yourcertificate.jks

keytool -v -importkeystore -srckeystore yourcertificate.p12 -srcstoretype PKCS12 -destkeystore yourcertificate.jks -deststoretype JKS

You can also check this link: http://shib.kuleuven.be/docs/ssl_commands.shtml#keytool

like image 135
authcate Avatar answered Sep 22 '22 10:09

authcate


These commands worked for me:

keytool -importkeystore -srckeystore yourp12file.p12 -destkeystore keystorefile.keystore -srcstoretype pkcs12
like image 27
William Grand Avatar answered Sep 23 '22 10:09

William Grand


You gonna use the flag -storetype PKCS12

First, create your keystore with its alias [ on this ex. mykeystore and myalias ]

keytool -genkey -alias myalias -keystore mykeystore -storetype PKCS12 -keyalg RSA -validity 3650 -keysize 2048

And just sign your APK

jarsigner -keystore mykeystore my.apk myalias

In case you need to align the app, use zipalign command before and do the signing with the aligned one, like so:

zipalign -f -p 4 my.apk myapk-aligned.apk

jarsigner -keystore mykeystore myapk-aligned.apk myalias

Flags used on zipalign

-f overwrite existing outfile

-p page align stored shared object files

-v if you want to see the verbose log, use that


The -validity 3650 was used to expire the signing in 10 years

like image 34
PYK Avatar answered Sep 23 '22 10:09

PYK