I'm trying to make some keystores using keytool
from the latest JRE (version 1.8.0_151). When I create the keystore using this command keytool -genkey -alias serverprivate -keystore server.private -keyalg rsa -storepass apassword -keypass apassword
it shows me this warning:
Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate
to PKCS12 which is an industry standard format using "keytool
-importkeystore -srckeystore server.private -destkeystore server.private
-deststoretype pkcs12".
So I type the command, and it says it's done and the old keystore was saved in server.private_old. But when I run keytool -list -keystore server.private
and type the password, it is still listed as JKS instead of PKCS12. Why is this?
update
It's not silently changed to pkcs12 either, because when I use KeyStore store = KeyStore.getInstance("pkcs12");
in java it throws an error, while it works fine when using getInstance("JKS");
update 2
And when using keytool -genkey -alias serverprivate -keystore server.private -storetype PKCS12 -keyalg rsa
it doesn't show me a warning, but still shows as a JKS keystore when using keytool -list server.private
.
It seems to be a bug in what keytool displays rather than what it does. Consider the following experiments.
(EDIT: bug report filed)
First, my jdk version is 1.8.0_152:
Now, create the keystore as you specified:
Now, following the instructions given:
But when we list it with keytool it still says JKS.
However, openssl can parse it as pkcs12 just fine.
and the following Java snippet can also parse it.
and the output is