crypt32: Create file store directly in CRYPT_FileNameOpenStoreW.
This commit is contained in:
parent
2373b8bc80
commit
60fcce5558
|
@ -227,6 +227,12 @@ PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
|
||||||
SetLastError(ERROR_PATH_NOT_FOUND);
|
SetLastError(ERROR_PATH_NOT_FOUND);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if ((dwFlags & CERT_STORE_READONLY_FLAG) &&
|
||||||
|
(dwFlags & CERT_FILE_STORE_COMMIT_ENABLE_FLAG))
|
||||||
|
{
|
||||||
|
SetLastError(E_INVALIDARG);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
access = GENERIC_READ;
|
access = GENERIC_READ;
|
||||||
if (dwFlags & CERT_FILE_STORE_COMMIT_ENABLE_FLAG)
|
if (dwFlags & CERT_FILE_STORE_COMMIT_ENABLE_FLAG)
|
||||||
|
@ -241,12 +247,27 @@ PWINECRYPT_CERTSTORE CRYPT_FileNameOpenStoreW(HCRYPTPROV hCryptProv,
|
||||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (file != INVALID_HANDLE_VALUE)
|
if (file != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
/* FIXME: need to check whether it's a serialized store; if not, fall
|
HCERTSTORE memStore;
|
||||||
* back to a PKCS#7 signed message, then to a single serialized cert.
|
|
||||||
*/
|
memStore = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
|
||||||
store = CertOpenStore(CERT_STORE_PROV_FILE, 0, hCryptProv, dwFlags,
|
CERT_STORE_CREATE_NEW_FLAG, NULL);
|
||||||
file);
|
if (memStore)
|
||||||
CloseHandle(file);
|
{
|
||||||
|
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;
|
return (PWINECRYPT_CERTSTORE)store;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue