Let's assume Java 21 here, as it is a long term support version.
There are some issues with the passwords:
- the default amount of iterations for the password-based key derivation function 2, i.e. PBKDF2, is 1000, which was the default very long ago;
- there are no methods of protecting the password when entered from console;
- there is no indication of password strength, other than requiring a minimum amount of 6 characters, which is of course not enough to be secure.
This basically means that any password used is hard to enter securely, while also making it easy to enter an altogether insecure password. Note that this is password based encryption (PBE), so attackers are able to crack the store using parallel processes having direct access to the data in the file. Basically you need to enter a password that has the strength of a symmetric key to have any kind of security, and this won't change much even if the number of iterations is set to e.g. 1,000,000. Using a password manager with at least a 16 character fully randomized password if you want to rely on the confidentiality.
In earlier Java versions (which I haven't all tested) they also used older algorithms:
- they are using 3DES to encrypt the private keys (not sure if it was 2 or 3 key 3DES, but both should not be used anymore);
- the 40-bit RC2 algorithms is used to encrypt the certificates, while the RC2 algorithm has been known to be broken for some time;
Certificates are not as sensitive as private keys of course, but they may still contain e.g. personal information which you might not want to leak, even if they are usually considered "public".
There are also some good things with newly generated key stores:
- they use SHA-256 for PBKDF2 but also for HMAC to provide authentication / integration;
- the newer key stores use AES-256 in CBC mode for providing confidentiality.
Using a hardware key store is currently one of the more logical options, or having a separate key store.
You can have a look at the inner construction of a new PKCS#12 / PFX key store here
keytool
does not support key password(s) different from the store password for PCKS12 (it does for JKS which is broken by design, and JCEKS which is nonstandard -- and BCFKS if you use Bouncy, as Swashbuckler notes). If you write your own tools the API does, but the resulting PKCS12 is not interoperable with anything else I know of, if that matters to you. $\endgroup$