Converting .jks to p12

Pkcs#12Jks

Pkcs#12 Problem Overview


How can I convert a .jks file to p12. jks is a java key store file so how can I convert it to the p12 format?

Pkcs#12 Solutions


Solution 1 - Pkcs#12

Convert a JKS file to PKCS12 format (Java 1.6.x and above)

keytool \
  -importkeystore \
  -srckeystore KEYSTORE.jks \
  -destkeystore KEYSTORE.p12 \
  -srcstoretype JKS \
  -deststoretype PKCS12 \
  -srcstorepass mysecret \
  -deststorepass mysecret \
  -srcalias myalias \
  -destalias myalias \
  -srckeypass mykeypass \
  -destkeypass mykeypass \
  -noprompt

from A few frequently used SSL commands

Solution 2 - Pkcs#12

JKS → P12:

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

P12 → JKS:

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

Solution 3 - Pkcs#12

Here is a one line command for the same.

keytool -importkeystore -srckeystore <MY_KEYSTORE.jks> -destkeystore <MY_FILE.p12> -srcstoretype JKS -deststoretype PKCS12 -deststorepass <PASSWORD_PKCS12> -srcalias <ALIAS_SRC> -destalias <ALIAS_DEST>

Explaining the parameters :

MY_FILE.p12: path to the PKCS#12 file (.p12 or .pfx extension) that is going to be created.
MY_KEYSTORE.jks: path to the keystore that you want to convert.
PASSWORD_PKCS12: password that will be requested at the PKCS#12 file opening.
ALIAS_SRC: name matching your certificate entry in the JKS keystore, "tomcat" for example.
ALIAS_DEST: name that will match your certificate entry in the PKCS#12 file, "tomcat" for example.

Solution 4 - Pkcs#12

This is for future folks, I found the above answers outdated and on mac I used this command to convert JKS to PKCS12

keytool -importkeystore -srckeystore srckeystore.jks -destkeystore destkeystore.jks -deststoretype pkcs12

Solution 5 - Pkcs#12

You can use, https://keystore-explorer.org/ Open your jks and save as p12 or open p12 and save as jks.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatrixView Question on Stackoverflow
Solution 1 - Pkcs#12Daniel SilveiraView Answer on Stackoverflow
Solution 2 - Pkcs#12bobView Answer on Stackoverflow
Solution 3 - Pkcs#12Ashish KView Answer on Stackoverflow
Solution 4 - Pkcs#12Kanishk GuptaView Answer on Stackoverflow
Solution 5 - Pkcs#12noobiusView Answer on Stackoverflow