I have a JKS with 2 keys generated using the keytool. The 2 keys have different passwords and the JKS password is again different from these 2 passwords.
If there is only one key in the key store, it works as expected. But adding another with a different password results in an UnrecoverableKeyException
. If the two keys have the same password, it still works fine.
Looking at some of the questions related to this: Java keystore with multiple keys and different passwords, Caused by: java.security.UnrecoverableKeyException: Cannot recover key it seems the solution is to use the same password. But that means there's no point in being able to set different passwords to different keys; we can just set a password to the whole key store and leave it at that.
Looking at Tomcat, it also seems to follow this approach of using the same password for both the store and the key.
Is this a restriction imposed by the JDK? Isn't there a way to make having different passwords for different keys work?