On Tue, 24 Nov 2026 10:57:43 GMT, Daisuke Yamazaki <[email protected]> wrote:
> I've verified the private key's location and deletion by > CspKeyContainerInfo.MachineKeyStore using PowerShell. > Would you prefer a native regression test to check the key's location as well? No need for a new test. Can you try using FFM to call a Windows API inside your Java test? >> src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp line 1933: >> >>> 1931: __leave; >>> 1932: } >>> 1933: >> >> Similar question on why you don't use location to determine the `keysetType`. > > Thank you for pointing that out. > Existing entries may have a certificate in `LOCALMACHINE` but a private key > in `CURRENTUSER`. > Using the provider handle let us determine the key’s actual location and > delete the correct container. Hmm, is this common? In this case, does that mean the certificate was added to two places so the same `PrivateKeyEntry` appears in both keystores? With your current code, the key and one cert is removed, and the other orphaned cert becomes a cert entry next time it's loaded. I think there are two questions here: 1. Shall we always remove the key? Suppose we have cert and key in CURRENTUSER and also cert in LOCALMACHINE. When we remove the entry in CURRENTUSER, I'm OK we remove both. But if we remove in LOCALMACHINE, shall we also remove the key and change the content of CURRENTUSER? 2. When a cert becomes orphaned, how should we deal with it? I somehow think it should not automatically becomes a cert entry. We currently use `CryptAcquireCertificatePrivateKey` to locate its key, but before that, we need to find a way to see if it has an associated key. ------------- PR Comment: https://git.openjdk.org/jdk/pull/33785#issuecomment-7133455675 PR Review Comment: https://git.openjdk.org/jdk/pull/33785#discussion_r4680945915
