diff --git a/dlls/crypt32/ctl.c b/dlls/crypt32/ctl.c index ffac6674dfd..65691bbf8a9 100644 --- a/dlls/crypt32/ctl.c +++ b/dlls/crypt32/ctl.c @@ -82,6 +82,27 @@ BOOL WINAPI CertAddCTLContextToStore(HCERTSTORE hCertStore, else toAdd = CertDuplicateCTLContext(pCtlContext); break; + case CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES: + if (existing) + { + LONG newer = CompareFileTime(&existing->pCtlInfo->ThisUpdate, + &pCtlContext->pCtlInfo->ThisUpdate); + + if (newer < 0) + { + toAdd = CertDuplicateCTLContext(pCtlContext); + CtlContext_CopyProperties(existing, pCtlContext); + } + else + { + TRACE("existing CTL is newer, not adding\n"); + SetLastError(CRYPT_E_EXISTS); + ret = FALSE; + } + } + else + toAdd = CertDuplicateCTLContext(pCtlContext); + break; case CERT_STORE_ADD_REPLACE_EXISTING: toAdd = CertDuplicateCTLContext(pCtlContext); break; diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 1519c968ee0..3b42893d3dd 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -893,6 +893,25 @@ BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore, else toAdd = CertDuplicateCertificateContext(pCertContext); break; + case CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES: + if (existing) + { + if (CompareFileTime(&existing->pCertInfo->NotBefore, + &pCertContext->pCertInfo->NotBefore) >= 0) + { + TRACE("existing certificate is newer, not adding\n"); + SetLastError(CRYPT_E_EXISTS); + ret = FALSE; + } + else + { + toAdd = CertDuplicateCertificateContext(pCertContext); + CertContext_CopyProperties(toAdd, existing); + } + } + else + toAdd = CertDuplicateCertificateContext(pCertContext); + break; default: FIXME("Unimplemented add disposition %d\n", dwAddDisposition); SetLastError(E_INVALIDARG); @@ -1016,6 +1035,27 @@ BOOL WINAPI CertAddCRLContextToStore(HCERTSTORE hCertStore, else toAdd = CertDuplicateCRLContext(pCrlContext); break; + case CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES: + if (existing) + { + LONG newer = CompareFileTime(&existing->pCrlInfo->ThisUpdate, + &pCrlContext->pCrlInfo->ThisUpdate); + + if (newer < 0) + { + toAdd = CertDuplicateCRLContext(pCrlContext); + CrlContext_CopyProperties(toAdd, existing); + } + else + { + TRACE("existing CRL is newer, not adding\n"); + SetLastError(CRYPT_E_EXISTS); + ret = FALSE; + } + } + else + toAdd = CertDuplicateCRLContext(pCrlContext); + break; case CERT_STORE_ADD_REPLACE_EXISTING: toAdd = CertDuplicateCRLContext(pCrlContext); break;