I have a Java keystore (.jks file) holding a single certificate. How can I create a .pfx file from this keystore?
From Java 6 onwards, keytool
has an -importkeystore
option, which should be able to convert a JKS store into a PKCS#12 store (.p12/.pfx):
keytool -importkeystore -srckeystore thekeystore.jks \
-srcstoretype JKS \
-destkeystore thekeystore.pfx \
-deststoretype PKCS12
It will ask you to enter a password for source and destination (jks, pfx) files
This guy() seems to have written a little Java class and batch file with good instructions to do this here: http://www.crionics.com/products/opensource/faq/signFree.htm#DownloadTools
If you want to do it yourself the key lines in the .bat file seem to be uses
keytool -export -rfc -keystore %KEYSTORE% -storepass %PASSWORD% -alias %ALIAS% > %CERT_64%
java -classpath %JAVACLASSPATH% ExportPrvKey %KEYSTORE% %PASSWORD% %ALIAS% > %PKEY_8%
openssl enc -in %PKEY_8% -a >> %PKEY_64%
openssl pkcs12 -inkey %PKEY_64% -in %CERT_64% -out %CERT_P12% -export
where ExportPrvKey does the step of extracting the private key from the keystore.
keytool -importkeystore -srckeystore [MY_KEYSTORE.jks] -destkeystore [MY_FILE.p12] -srcstoretype JKS -deststoretype PKCS12
Then it will request your passphrases and BAM - good to go, tried just last night worked great.
you may have to change dir to your java jdk, or jre bin folder first, then include a full path to your current Keystore, and dest .p12 file.
You can export a PFX file including private key, with the following command:
keytool -importkeystore -deststorepass secret -destkeypass secret -destkeystore KEYSTOREFILE.jks -srckeystore PFXFILE.pfx -srcstoretype PKCS12 -srcstorepass secret
© 2022 - 2024 — McMap. All rights reserved.