Simple CertDllOpenStoreProv makes IE importing PFX failed without reason
- From: <ebooktech@xxxxxxxx>
- Date: Mon, 22 May 2006 23:55:23 +0800
Although IE pops message: the certificate was imported successfully, failed
in fact.
The code is attatched. Any clue is appreciated.
Richard
static const char l_StoreProvider[] = "SampleStore";
static const WCHAR l_StoreProviderW[] = L"SampleStore";
#define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
BOOL WINAPI CertDllOpenStoreProv(
IN LPCSTR lpszStoreProvider,
IN DWORD dwEncodingType,
IN HCRYPTPROV hCryptProv,
IN DWORD dwFlags,
IN const void *pvPara,
IN HCERTSTORE hCertStore,
IN OUT PCERT_STORE_PROV_INFO pStoreProvInfo
)
{
return TRUE;
}
STDAPI DllRegisterServer(void)
{
WCHAR szDllFile[MAX_PATH];
if (GetModuleFileNameW(g_hModule, szDllFile, MAX_PATH) == 0)
return noerror;
if (!CryptRegisterOIDFunction(0, CRYPT_OID_OPEN_STORE_PROV_FUNC,
l_StoreProvider, szDllFile, CRYPT_OID_OPEN_STORE_PROV_FUNC))
return NOERROR;
CERT_PHYSICAL_STORE_INFO PhysicalStore;
ZeroMemory(&PhysicalStore, sizeof(PhysicalStore));
PhysicalStore.cbSize = sizeof(PhysicalStore);
PhysicalStore.pszOpenStoreProvider = (LPSTR)l_StoreProvider;
PhysicalStore.dwFlags = CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG;
PhysicalStore.dwPriority = 1;
PhysicalStore.dwOpenEncodingType = ENCODING;
PhysicalStore.OpenParameters.cbData = strlen(l_StoreProvider);
PhysicalStore.OpenParameters.pbData = (PBYTE)l_StoreProvider;
CertRegisterPhysicalStore(L"MY",
CERT_STORE_CREATE_NEW_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,
l_StoreProviderW, &PhysicalStore, NULL);
return NOERROR;
}
// The DllUnregisterServer Entry Point
STDAPI DllUnregisterServer(void)
{
if (!CertUnregisterPhysicalStore(L"MY",
CERT_STORE_DELETE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,
l_StoreProviderW))
return NOERROR;
CryptUnregisterOIDFunction(0, CRYPT_OID_OPEN_STORE_PROV_FUNC,
l_StoreProvider);
return NOERROR;
}
.
- Prev by Date: smart card and signing email => pin dialog => csp??
- Next by Date: RE: Confused by CryptoAPI
- Previous by thread: smart card and signing email => pin dialog => csp??
- Next by thread: SSL SSPI ClientCertificate
- Index(es):