Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

keystore

jks

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.

like image 377
Fang Avatar asked Sep 23 '16 09:09

Fang


People also ask

How do I convert a PEM file to JKS?

We'll use a combination of keytool and openssl commands to convert from PEM to JKS. The keytool command comes with the JDK (Java Development Kit) and is used to convert from PEM to PKCS12. The second command, openssl, needs to be downloaded, and its role is to convert from PKCS12 to JKS.

What is PEM file for keystore?

The tool will prompt us for the PKCS#12 KeyStore password and a PEM passphrase for each alias. The PEM passphrase is used to encrypt the resulting private key. keystore. pem will contain all of the keys and certificates from the KeyStore.


1 Answers

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
like image 121
Fang Avatar answered Sep 21 '22 15:09

Fang