PKCS12 to JKS conversion failure

2019-05-27 01:53发布

问题:

I'm trying to convert a PKCS12 format file to a JKS keystore using the command:

keytool -v -importkeystore -trustcacerts -srckeystore cert.p12 -srcstoretype PKCS12 -destkeystore md_keystore.jks -deststoretype JKS

This returns the following message:

0 entries successfully imported, 0 entries failed or cancelled

I've taken a look at the cert.p12 file using openSSL and it appears to be fine - it contains the full certificate chain and the private key. There is no stacktrace being returned either and the resulting keystore file is also empty.

Anyone have any ideas why keystore would fail to import a seemingly valid certificate, and yet not produce any stacktraces etc?

回答1:

I have imported some PKCS12 certificates recently using this command line:

keytool -importkeystore -srckeystore cert.p12 -srcstoretype PKCS12 -srcstorepass certificatePassword -keystore keystore_file_name.jks -storepass keystore_password


回答2:

Tims, I bet you you set an empty passphrase to encrypt your p12 key store.

Try to create the p12 again with a non empty value. I had the same problem and this solved for me. I have not figured out how to make keytool to accept p12 files with an empty passphrese though.