8234744: KeyStore.store can write wrong type of file

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2019-12-03 14:38:18 +08:00
parent 50714b0fb9
commit bc19b64856
2 changed files with 70 additions and 4 deletions

View file

@ -217,9 +217,9 @@ public class KeyStoreDelegator extends KeyStoreSpi {
try {
@SuppressWarnings("deprecation")
KeyStoreSpi tmp = primaryKeyStore.newInstance();
tmp.engineLoad(bufferedStream, password);
keystore = tmp;
type = primaryType;
keystore.engineLoad(bufferedStream, password);
} catch (Exception e) {
@ -236,11 +236,11 @@ public class KeyStoreDelegator extends KeyStoreSpi {
}
@SuppressWarnings("deprecation")
KeyStoreSpi tmp= secondaryKeyStore.newInstance();
KeyStoreSpi tmp = secondaryKeyStore.newInstance();
bufferedStream.reset();
tmp.engineLoad(bufferedStream, password);
keystore = tmp;
type = secondaryType;
bufferedStream.reset();
keystore.engineLoad(bufferedStream, password);
if (debug != null) {
debug.println("WARNING: switching from " +