Commit e5256d98 authored by Mounir IDRASSI's avatar Mounir IDRASSI Committed by Alexandre Julliard

crypt32: Fix CertAddCertificateContextToStore when called with CERT_STORE_ADD_USE_EXISTING.

parent b4536734
...@@ -2160,7 +2160,12 @@ BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore, ...@@ -2160,7 +2160,12 @@ BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore,
break; break;
case CERT_STORE_ADD_USE_EXISTING: case CERT_STORE_ADD_USE_EXISTING:
if (existing) if (existing)
{
CertContext_CopyProperties(existing, pCertContext); CertContext_CopyProperties(existing, pCertContext);
*ppStoreContext = CertDuplicateCertificateContext(existing);
}
else
toAdd = CertDuplicateCertificateContext(pCertContext);
break; break;
default: default:
FIXME("Unimplemented add disposition %d\n", dwAddDisposition); FIXME("Unimplemented add disposition %d\n", dwAddDisposition);
......
...@@ -134,6 +134,7 @@ static void testAddCert(void) ...@@ -134,6 +134,7 @@ static void testAddCert(void)
HCERTSTORE store; HCERTSTORE store;
HCERTSTORE collection; HCERTSTORE collection;
PCCERT_CONTEXT context; PCCERT_CONTEXT context;
PCCERT_CONTEXT copyContext;
BOOL ret; BOOL ret;
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
...@@ -274,6 +275,15 @@ static void testAddCert(void) ...@@ -274,6 +275,15 @@ static void testAddCert(void)
CERT_STORE_ADD_REPLACE_EXISTING, NULL); CERT_STORE_ADD_REPLACE_EXISTING, NULL);
ok(ret, "CertAddCertificateContextToStore failed: %08x\n", ok(ret, "CertAddCertificateContextToStore failed: %08x\n",
GetLastError()); GetLastError());
/* use the existing certificate and ask for a copy of the context*/
copyContext = NULL;
ret = CertAddCertificateContextToStore(collection, context,
CERT_STORE_ADD_USE_EXISTING, &copyContext);
ok(ret, "CertAddCertificateContextToStore failed: %08x\n",
GetLastError());
ok(copyContext != NULL, "Expected on output a non NULL copyContext\n");
if (copyContext)
CertFreeCertificateContext(copyContext);
/* but adding a new certificate isn't allowed. */ /* but adding a new certificate isn't allowed. */
ret = CertAddCertificateContextToStore(collection, context, ret = CertAddCertificateContextToStore(collection, context,
CERT_STORE_ADD_ALWAYS, NULL); CERT_STORE_ADD_ALWAYS, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment