Search code examples
x509keytoolpempfxjks

getting error while trying to convert pfx without password to jks


When I'm trying to convert pfx file, which was generated without password, to jks I get a WARNING WARNING etc... message from keytool, and an error afterwards

When I do the same with an password protected pfx, then everything is fine.

Can anyone suggest what I can do !? maybe a conversion from other formats or using other tools ?

ps. I did also conversion to pem, and pem to jks, but it failed, because it was not an x509 cert.

EDIT

keytool.exe -importkeystore -srckeystore "C:\Users\rodislav.moldovan\Projects
\ceva.pfx" -srcstoretype pkcs12 -destkeystore "C:\Users\rodislav.mol
dovan\Projects\ceva.jks" -deststoretype JKS
Enter destination keystore password: ******
Re-enter new password: ******
Enter source keystore password: // pressed enter, because there is no pass

*****************  WARNING WARNING WARNING  *****************
* The integrity of the information stored in the srckeystore*
* has NOT been verified!  In order to verify its integrity, *
* you must provide the srckeystore password.                *
*****************  WARNING WARNING WARNING  *****************

keytool error: java.security.UnrecoverableKeyException: Get Key failed: null

Solution

  • You can do it by making a p12 keystore first with OpenSSL and then convert it into JKS format with Keytool.

    OpenSSL for CER & PVK file > P12

    openssl pkcs12 -export -name servercert -in selfsignedcert.crt -inkey serverprivatekey.key -out myp12keystore.p12

    Keytool for p12 > JKS

    keytool -importkeystore -destkeystore mykeystore.jks -srckeystore myp12keystore.p12 -srcstoretype pkcs12 -alias servercert