63

如何将.jks文件转换为p12. jks是一个 java 密钥存储文件,那么如何将其转换为p12格式?

4

5 回答 5

102

将 JKS 文件转换为 PKCS12 格式(Java 1.6.x 及更高版本)

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

来自几个常用的 SSL 命令

于 2010-06-16T14:14:12.120 回答
52

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
于 2015-05-02T21:28:00.993 回答
4

这是相同的单行命令。

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

解释参数:

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.
于 2016-09-15T05:28:05.700 回答
2

这是给未来的人的,我发现上面的答案已经过时了,在 mac 上我使用这个命令转换JKSPKCS12

keytool -importkeystore -srckeystore srckeystore.jks -destkeystore destkeystore.jks -deststoretype pkcs12
于 2019-02-27T11:49:47.773 回答
1

您可以使用https://keystore-explorer.org/ 打开您的 jks 并另存为 p12 或打开 p12 并另存为 jks。

于 2019-03-04T18:12:23.987 回答