JCE: zero WolfSSLKeyStore PKCS8 private key buffer after native check

pull/212/head
Ruby Martin 2026-04-24 12:32:33 -06:00
parent 570faa424e
commit dc3d7a6c83
1 changed files with 9 additions and 6 deletions

View File

@ -1459,11 +1459,14 @@ public class WolfSSLKeyStore extends KeyStoreSpi {
if (pkcs8Key == null || pkcs8Key.length == 0) {
throw new KeyStoreException("Bad PrivateKey PKCS#8 encoding");
}
match = X509CheckPrivateKey(derCert, pkcs8Key);
if (!match) {
throw new KeyStoreException("X509Certificate does not match " +
"provided private key");
try {
match = X509CheckPrivateKey(derCert, pkcs8Key);
if (!match) {
throw new KeyStoreException("X509Certificate does not match " +
"provided private key");
}
} finally {
Arrays.fill(pkcs8Key, (byte)0);
}
}
@ -1986,7 +1989,7 @@ public class WolfSSLKeyStore extends KeyStoreSpi {
log("KeyStore successfully stored to OutputStream");
return;
return;
}
/**