One of Chrome crypto plugins depends on this.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/crypt32/cert.c | 1 + dlls/crypt32/tests/cert.c | 59 ++++++++++++++------------------------- 2 files changed, 22 insertions(+), 38 deletions(-)
diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index 33811dfadc1..81ebb59d27c 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -1006,6 +1006,7 @@ BOOL WINAPI CryptAcquireCertificatePrivateKey(PCCERT_CONTEXT pCert, HeapFree(GetProcessHeap(), 0, info); if (cert_in_store) CertFreeCertificateContext(cert_in_store); + if (ret) SetLastError(0); return ret; }
diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index b96f94cc662..bc79b4931f7 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -3906,55 +3906,42 @@ static void testAcquireCertPrivateKey(void) CERT_KEY_CONTEXT keyContext;
/* Don't cache provider */ + SetLastError(0xdeadbeef); ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); - if (ret) - { - ok(callerFree, "Expected callerFree to be TRUE\n"); - CryptReleaseContext(certCSP, 0); - } + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08x\n", GetLastError()); + ok(callerFree, "Expected callerFree to be TRUE\n"); + CryptReleaseContext(certCSP, 0);
+ SetLastError(0xdeadbeef); ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, NULL, NULL); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08x\n", GetLastError()); CryptReleaseContext(certCSP, 0);
/* Use the key prov info's caching (there shouldn't be any) */ + SetLastError(0xdeadbeef); ret = pCryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); - if (ret) - { - ok(callerFree, "Expected callerFree to be TRUE\n"); - CryptReleaseContext(certCSP, 0); - } + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08x\n", GetLastError()); + ok(callerFree, "Expected callerFree to be TRUE\n"); + CryptReleaseContext(certCSP, 0);
/* Cache it (and check that it's cached) */ + SetLastError(0xdeadbeef); ret = pCryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_CACHE_FLAG, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08x\n", GetLastError()); ok(!callerFree, "Expected callerFree to be FALSE\n"); size = sizeof(keyContext); ret = CertGetCertificateContextProperty(cert, CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); - ok(ret || - broken(!ret), /* win95 */ - "CertGetCertificateContextProperty failed: %08x\n", - GetLastError()); + ok(ret, "CertGetCertificateContextProperty failed: %08x\n", GetLastError());
/* Remove the cached provider */ CryptReleaseContext(keyContext.hCryptProv, 0); @@ -3965,21 +3952,17 @@ static void testAcquireCertPrivateKey(void) CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo); /* Now use the key prov info's caching */ + SetLastError(0xdeadbeef); ret = pCryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec, &callerFree); - ok(ret || - broken(!ret), /* win95 */ - "CryptAcquireCertificatePrivateKey failed: %08x\n", - GetLastError()); + ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "got %08x\n", GetLastError()); ok(!callerFree, "Expected callerFree to be FALSE\n"); size = sizeof(keyContext); ret = CertGetCertificateContextProperty(cert, CERT_KEY_CONTEXT_PROP_ID, &keyContext, &size); - ok(ret || - broken(!ret), /* win95 */ - "CertGetCertificateContextProperty failed: %08x\n", - GetLastError()); + ok(ret, "CertGetCertificateContextProperty failed: %08x\n", GetLastError()); CryptReleaseContext(certCSP, 0);
CryptDestroyKey(key);