On Sun, 22 Nov 2026 14:03:12 GMT, Daisuke Yamazaki <[email protected]> wrote:

>> Please review this fix for SunMSCAPI storing and removing certs in 
>> `CURRENTUSER` even when a `LOCALMACHINE` keystore is selected.
>> 
>> The native `storeCertificate` and `removeCertificate` methods currently use 
>> `CertOpenSystemStore`, which opens the `CURRENTUSER` store.
>> This fix passes the store location through JNI and uses `CertOpenStore` with 
>> `CERT_SYSTEM_STORE_LOCAL_MACHINE` for `LOCALMACHINE` keystores.
>> 
>> The manual regression test `LocalMachineStore` verifies certificate 
>> placement and deletion; the test requires administrator privileges.
>> 
>> Testing:
>> - `LocalMachineStore`
>> - manual `keytool -genkeypair`, `-list` and `-delete`
>> 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Daisuke Yamazaki has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Private key fix

src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKeyStore.java line 
196:

> 194:             if (privateKey != null) {
> 195:                 if (privateKey.getHCryptKey() != 0) {
> 196:                     long hCryptProvider = privateKey.getHCryptProvider();

Since this is used in both cases, can we move it before the `if` block?

src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp line 1510:

> 1508:         else if (jCertStoreLocation == KEYSTORE_LOCATION_LOCALMACHINE) {
> 1509:             hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, 
> NULL,
> 1510:                 CERT_SYSTEM_STORE_LOCAL_MACHINE | 
> CERT_STORE_MAXIMUM_ALLOWED_FLAG, pszCertStoreName);

Since we are modifying the keystore, maybe there is no need for 
`CERT_STORE_MAXIMUM_ALLOWED_FLAG`? Same with the open in remove below.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/33785#discussion_r4660267807
PR Review Comment: https://git.openjdk.org/jdk/pull/33785#discussion_r4660270832

Reply via email to