From 60fcce5558c1747f7db09e9cd90b9883f9d9cf2d Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Fri, 28 Sep 2007 08:37:47 -0700 Subject: [PATCH] crypt32: Create file store directly in CRYPT_FileNameOpenStoreW. --- dlls/crypt32/filestore.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/dlls/crypt32/filestore.c b/dlls/crypt32/filestore.c index fc89c0a2d6..ffd9889759 100644 --- a/dlls/crypt32/filestore.c +++ b/dlls/crypt32/filestore.c @@ -227,6 +227,12 @@ PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv, SetLastError(ERROR_PATH_NOT_FOUND); return NULL; } + if ((dwFlags & CERT_STORE_READONLY_FLAG) && + (dwFlags & CERT_FILE_STORE_COMMIT_ENABLE_FLAG)) + { + SetLastError(E_INVALIDARG); + return NULL; + } access = GENERIC_READ; if (dwFlags & CERT_FILE_STORE_COMMIT_ENABLE_FLAG) @@ -241,12 +247,27 @@ PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv, FILE_ATTRIBUTE_NORMAL, NULL); if (file != INVALID_HANDLE_VALUE) { - /* FIXME: need to check whether it's a serialized store; if not, fall - * back to a PKCS#7 signed message, then to a single serialized cert. - */ - store = CertOpenStore(CERT_STORE_PROV_FILE, 0, hCryptProv, dwFlags, - file); - CloseHandle(file); + HCERTSTORE memStore; + + memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, + CERT_STORE_CREATE_NEW_FLAG, NULL); + if (memStore) + { + if (CRYPT_ReadSerializedStoreFromFile(file, memStore)) + { + store = CRYPT_CreateFileStore(dwFlags, memStore, file); + /* File store doesn't need crypto provider, so close it */ + if (hCryptProv && + !(dwFlags & CERT_STORE_NO_CRYPT_RELEASE_FLAG)) + CryptReleaseContext(hCryptProv, 0); + } + else + { + /* FIXME: fall back to a PKCS#7 signed message, then to a + * single serialized cert. + */ + } + } } return (PWINECRYPT_CERTSTORE)store; } -- 2.32.0.93.g670b81a890