[PATCH v2 0/2] MR10530: crypt32: Add CERT_STORE_NO_CRYPT_RELEASE_FLAG to CertOpenStore() flags when called from CertOpenSystemStore().
-- v2: crypt32: Add CERT_STORE_NO_CRYPT_RELEASE_FLAG to CertOpenStore() flags when called from CertOpenSystemStore(). crypt32/tests: Add some tests for CertOpenSystemStore() with real provider handle. https://gitlab.winehq.org/wine/wine/-/merge_requests/10530
From: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/crypt32/tests/store.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c index 678d4810d8b..f14611d7e41 100644 --- a/dlls/crypt32/tests/store.c +++ b/dlls/crypt32/tests/store.c @@ -2064,6 +2064,9 @@ static void testSerializedStore(void) static void testCertOpenSystemStore(void) { HCERTSTORE store; + HCRYPTPROV prov; + BOOL ret; + DWORD size, pp_type; store = CertOpenSystemStoreW(0, NULL); ok(!store && GetLastError() == E_INVALIDARG, @@ -2079,6 +2082,25 @@ static void testCertOpenSystemStore(void) CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_DELETE_FLAG, L"Bogus"); RegDeleteKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\SystemCertificates\\Bogus"); + + ret = CryptAcquireContextA(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); + ok(ret, "CryptAcquireContext failed: %08lx\n", GetLastError()); + + store = CertOpenSystemStoreW(prov, L"My"); + ok(store != 0, "CertOpenSystemStore failed: %08lx\n", GetLastError()); + + size = sizeof(pp_type); + pp_type = 0xdeadbeef; + ret = CryptGetProvParam(prov, PP_PROVTYPE, (BYTE *)&pp_type, &size, 0); + todo_wine + ok(ret, "CryptGetProvParam failed: %08lx\n", GetLastError()); + todo_wine + ok(pp_type == PROV_RSA_FULL, "got %lu\n", pp_type); + + CertCloseStore(store, 0); + ret = CryptReleaseContext(prov, 0); + todo_wine + ok(ret, "CryptReleaseContext: %08lx\n", GetLastError()); } static const struct -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10530
From: Dmitry Timoshkov <dmitry@baikal.ru> This prevents closing a not owned provider handle. Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/crypt32/store.c | 4 ++-- dlls/crypt32/tests/store.c | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 54b16ab8fa1..ac17a3d4768 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -948,7 +948,7 @@ HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv, return 0; } return CertOpenStore(CERT_STORE_PROV_SYSTEM_A, 0, hProv, - CERT_SYSTEM_STORE_CURRENT_USER, szSubSystemProtocol); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_NO_CRYPT_RELEASE_FLAG, szSubSystemProtocol); } HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv, @@ -960,7 +960,7 @@ HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv, return 0; } return CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, hProv, - CERT_SYSTEM_STORE_CURRENT_USER, szSubSystemProtocol); + CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_NO_CRYPT_RELEASE_FLAG, szSubSystemProtocol); } PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev) diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c index f14611d7e41..33e4e34a9e8 100644 --- a/dlls/crypt32/tests/store.c +++ b/dlls/crypt32/tests/store.c @@ -2092,14 +2092,11 @@ static void testCertOpenSystemStore(void) size = sizeof(pp_type); pp_type = 0xdeadbeef; ret = CryptGetProvParam(prov, PP_PROVTYPE, (BYTE *)&pp_type, &size, 0); - todo_wine ok(ret, "CryptGetProvParam failed: %08lx\n", GetLastError()); - todo_wine ok(pp_type == PROV_RSA_FULL, "got %lu\n", pp_type); CertCloseStore(store, 0); ret = CryptReleaseContext(prov, 0); - todo_wine ok(ret, "CryptReleaseContext: %08lx\n", GetLastError()); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10530
On Wed Apr 1 07:51:10 2026 +0000, Hans Leidekker wrote:
Can we test this? Maybe call CryptReleaseContext() and check the return value / last error? Sure.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10530#note_134624
This merge request was approved by Hans Leidekker. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10530
participants (3)
-
Dmitry Timoshkov -
Dmitry Timoshkov (@dmitry) -
Hans Leidekker (@hans)