Commit c7d1082b authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

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

parent fe9e2399
...@@ -169,7 +169,7 @@ PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType, ...@@ -169,7 +169,7 @@ PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType,
cert->pbCertEncoded = data; cert->pbCertEncoded = data;
cert->cbCertEncoded = cbCertEncoded; cert->cbCertEncoded = cbCertEncoded;
cert->pCertInfo = certInfo; cert->pCertInfo = certInfo;
cert->hCertStore = 0; cert->hCertStore = &empty_store;
} }
end: end:
......
...@@ -231,6 +231,7 @@ typedef enum _CertStoreType { ...@@ -231,6 +231,7 @@ typedef enum _CertStoreType {
StoreTypeMem, StoreTypeMem,
StoreTypeCollection, StoreTypeCollection,
StoreTypeProvider, StoreTypeProvider,
StoreTypeEmpty
} CertStoreType; } CertStoreType;
typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST; typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
...@@ -420,6 +421,9 @@ BOOL ContextList_Remove(struct ContextList *list, void *context) DECLSPEC_HIDDEN ...@@ -420,6 +421,9 @@ BOOL ContextList_Remove(struct ContextList *list, void *context) DECLSPEC_HIDDEN
void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN; void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN;
extern WINECRYPT_CERTSTORE empty_store;
void init_empty_store(void) DECLSPEC_HIDDEN;
/** /**
* Utilities. * Utilities.
*/ */
......
...@@ -42,6 +42,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved) ...@@ -42,6 +42,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved)
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
hInstance = hInst; hInstance = hInst;
DisableThreadLibraryCalls(hInst); DisableThreadLibraryCalls(hInst);
init_empty_store();
crypt_oid_init(); crypt_oid_init();
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
......
...@@ -1488,3 +1488,75 @@ BOOL WINAPI CertRegisterPhysicalStore(const void *pvSystemStore, DWORD dwFlags, ...@@ -1488,3 +1488,75 @@ BOOL WINAPI CertRegisterPhysicalStore(const void *pvSystemStore, DWORD dwFlags,
dwFlags, debugstr_w(pwszStoreName), pStoreInfo, pvReserved); dwFlags, debugstr_w(pwszStoreName), pStoreInfo, pvReserved);
return FALSE; 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);
}
...@@ -660,7 +660,6 @@ static void testCreateCert(void) ...@@ -660,7 +660,6 @@ static void testCreateCert(void)
selfSignedCert, sizeof(selfSignedCert)); selfSignedCert, sizeof(selfSignedCert));
ok(cert != NULL, "creating cert failed: %08x\n", GetLastError()); ok(cert != NULL, "creating cert failed: %08x\n", GetLastError());
/* Even in-memory certs are expected to have a store associated with them */ /* 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"); 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 /* The cert doesn't have the archived property set (which would imply it
* doesn't show up in enumerations.) * doesn't show up in enumerations.)
......
...@@ -2515,7 +2515,7 @@ static void testEmptyStore(void) ...@@ -2515,7 +2515,7 @@ static void testEmptyStore(void)
cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
ok(cert != NULL, "CertCreateCertificateContext failed\n"); 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) { if(!cert->hCertStore) {
CertFreeCertificateContext(cert); CertFreeCertificateContext(cert);
return; return;
...@@ -2555,6 +2555,8 @@ static void testEmptyStore(void) ...@@ -2555,6 +2555,8 @@ static void testEmptyStore(void)
ok(res, "CertDeleteCertificateContextFromStore failed\n"); ok(res, "CertDeleteCertificateContextFromStore failed\n");
ok(cert3->hCertStore == store, "Unexpected hCertStore\n"); ok(cert3->hCertStore == store, "Unexpected hCertStore\n");
CertFreeCertificateContext(cert3);
CertCloseStore(store, 0); CertCloseStore(store, 0);
res = CertCloseStore(cert->hCertStore, CERT_CLOSE_STORE_CHECK_FLAG); res = CertCloseStore(cert->hCertStore, CERT_CLOSE_STORE_CHECK_FLAG);
......
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