我正在关注Microsoft Example C Program: Creating a Certificate Chain
中的本教程但是我在下一个块中得到了Unhandled异常调用CertCreateCertificateChainEngine函数
if(CertCreateCertificateChainEngine(
&ChainConfig,
&hChainEngine)) {
printf("A chain engine has been created.\n");
}
else {
MyHandleError("The engine creation function failed.");
}
异常消息是:
Unhandled exception at 0x7535F61A (crypt32.dll) in capi_verify.exe: 0xC0000005: Access violation writing location 0xCCCCCCD0.
以下是变量的定义方式:
HCERTCHAINENGINE hChainEngine = NULL;
CERT_CHAIN_ENGINE_CONFIG ChainConfig;
并将ChainConfig结构初始化为:
ChainConfig.cbSize = sizeof(CERT_CHAIN_ENGINE_CONFIG);
ChainConfig.hRestrictedRoot= NULL ;
ChainConfig.hRestrictedTrust= NULL ;
ChainConfig.hRestrictedOther= NULL ;
ChainConfig.cAdditionalStore=0 ;
ChainConfig.rghAdditionalStore = NULL ;
ChainConfig.dwFlags = CERT_CHAIN_CACHE_END_CERT;
ChainConfig.dwUrlRetrievalTimeout= 0 ;
ChainConfig.MaximumCachedCertificates=0 ;
ChainConfig.CycleDetectionModulus = 0;
CertCreateCertificateChainEngine函数具有以下签名:
BOOL WINAPI CertCreateCertificateChainEngine(
_In_ PCERT_CHAIN_ENGINE_CONFIG pConfig,
_Out_ HCERTCHAINENGINE *phChainEngine
);
这是ChainConfig的调试截图:
hChainEngine显示为NULL,例如00000000
答案 0 :(得分:0)
我想出了这个例外的原因。问题是由于在Windows 7之后进行了更改,我们应该初始化hExclusivrTrustPeople和hExclusiveRoot成员。所以上面提到的文章对于较新的Windows系统来说已经过时了