crypt32: Added new empty store type and use it for creating certificates with no store.

This commit is contained in:
Jacek Caban 2013-10-14 14:46:40 +02:00 committed by Alexandre Julliard
parent fe9e23998a
commit c7d1082b4f
6 changed files with 81 additions and 3 deletions

View file

@ -169,7 +169,7 @@ PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType,
cert->pbCertEncoded = data;
cert->cbCertEncoded = cbCertEncoded;
cert->pCertInfo = certInfo;
cert->hCertStore = 0;
cert->hCertStore = &empty_store;
}
end:

View file

@ -231,6 +231,7 @@ typedef enum _CertStoreType {
StoreTypeMem,
StoreTypeCollection,
StoreTypeProvider,
StoreTypeEmpty
} CertStoreType;
typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
@ -420,6 +421,9 @@ BOOL ContextList_Remove(struct ContextList *list, void *context) DECLSPEC_HIDDEN
void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN;
extern WINECRYPT_CERTSTORE empty_store;
void init_empty_store(void) DECLSPEC_HIDDEN;
/**
* Utilities.
*/

View file

@ -42,6 +42,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved)
case DLL_PROCESS_ATTACH:
hInstance = hInst;
DisableThreadLibraryCalls(hInst);
init_empty_store();
crypt_oid_init();
break;
case DLL_PROCESS_DETACH:

View file

@ -1488,3 +1488,75 @@ BOOL WINAPI CertRegisterPhysicalStore(const void *pvSystemStore, DWORD dwFlags,
dwFlags, debugstr_w(pwszStoreName), pStoreInfo, pvReserved);
return FALSE;
}
static void EmptyStore_addref(WINECRYPT_CERTSTORE *store)
{
TRACE("(%p)\n", store);
}
static DWORD EmptyStore_release(WINECRYPT_CERTSTORE *store, DWORD flags)
{
TRACE("(%p)\n", store);
return E_UNEXPECTED;
}
static BOOL EmptyStore_add(WINECRYPT_CERTSTORE *store, void *context,
void *replace, const void **ret_context)
{
TRACE("(%p, %p, %p, %p)\n", store, context, replace, ret_context);
/* FIXME: We should clone the context */
if(ret_context) {
Context_AddRef(context);
*ret_context = context;
}
return TRUE;
}
static void *EmptyStore_enum(WINECRYPT_CERTSTORE *store, void *prev)
{
TRACE("(%p, %p)\n", store, prev);
SetLastError(CRYPT_E_NOT_FOUND);
return FALSE;
}
static BOOL EmptyStore_delete(WINECRYPT_CERTSTORE *store, void *context)
{
return TRUE;
}
static BOOL EmptyStore_control(WINECRYPT_CERTSTORE *store, DWORD flags, DWORD ctrl_type, void const *ctrl_para)
{
TRACE("()\n");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
static const store_vtbl_t EmptyStoreVtbl = {
EmptyStore_addref,
EmptyStore_release,
EmptyStore_control,
{
EmptyStore_add,
EmptyStore_enum,
EmptyStore_delete
}, {
EmptyStore_add,
EmptyStore_enum,
EmptyStore_delete
}, {
EmptyStore_add,
EmptyStore_enum,
EmptyStore_delete
}
};
WINECRYPT_CERTSTORE empty_store;
void init_empty_store(void)
{
CRYPT_InitStore(&empty_store, CERT_STORE_READONLY_FLAG, StoreTypeEmpty, &EmptyStoreVtbl);
}

View file

@ -660,7 +660,6 @@ static void testCreateCert(void)
selfSignedCert, sizeof(selfSignedCert));
ok(cert != NULL, "creating cert failed: %08x\n", GetLastError());
/* Even in-memory certs are expected to have a store associated with them */
todo_wine
ok(cert->hCertStore != NULL, "expected created cert to have a store\n");
/* The cert doesn't have the archived property set (which would imply it
* doesn't show up in enumerations.)

View file

@ -2515,7 +2515,7 @@ static void testEmptyStore(void)
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
ok(cert != NULL, "CertCreateCertificateContext failed\n");
todo_wine ok(cert->hCertStore != NULL, "cert->hCertStore == NULL\n");
ok(cert->hCertStore != NULL, "cert->hCertStore == NULL\n");
if(!cert->hCertStore) {
CertFreeCertificateContext(cert);
return;
@ -2555,6 +2555,8 @@ static void testEmptyStore(void)
ok(res, "CertDeleteCertificateContextFromStore failed\n");
ok(cert3->hCertStore == store, "Unexpected hCertStore\n");
CertFreeCertificateContext(cert3);
CertCloseStore(store, 0);
res = CertCloseStore(cert->hCertStore, CERT_CLOSE_STORE_CHECK_FLAG);