我怎么能把.jks
文件转换为p12
。 jks
是一个java密钥库文件,那么如何将其转换为p12
格式?
将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
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
这是一行的一行命令。
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.
following page为您提供了一组有用的SSL命令,您将找到答案。
你可以使用,https://keystore-explorer.org/打开你的jks并保存为p12或打开p12并保存为jks。
这是为了未来的人,我发现上面的答案已经过时,在mac上我用这个命令将JKS
转换为PKCS12
keytool -importkeystore -srckeystore srckeystore.jks -destkeystore destkeystore.jks -deststoretype pkcs12