How to import x509.pem pk8 file into jks-keystore?

Fang picture Fang · Sep 23, 2016 · Viewed 9.8k times · Source

I have already tried to use the command

keytool -import -keystore *.jks -alias alias_name -keypass alias_passwd -file *.x509.pem` (no *.pk8 file)

but when I use the jks to sign the APK, a

trusted certificate entries are not password-protected

error occures.

Answer

Fang picture Fang · Oct 20, 2016
openssl pkcs8 -in platform.pk8 -inform DER -outform PEM -out platform.priv.pem -nocrypt

openssl pkcs12 -export -in platform.x509.pem -inkey platform.priv.pem -out platform.pk12 -name android

keytool -importkeystore -destkeystore platform.jks -srckeystore platform.pk12 -srcstoretype PKCS12 -srcstorepass android -alias android