我在 certcreatecertificatchainengine func 上得到 0x80070057 错误代码
I get 0x80070057 error code on certcreatecertificatechainengine func
我使用 visual studio 2013 和 windows 7 32 位。
我想通过根证书和证书链验证数字签名。
所以我在 certcreatecertificatchainengine() 中得到 0x80070057 错误代码。
bool result = false;
HCERTCHAINENGINE hChainEngine;
CERT_CHAIN_ENGINE_CONFIG ChainConfig;
PCCERT_CHAIN_CONTEXT pChainContext;
//PCCERT_CHAIN_CONTEXT pDupContext;
HCERTSTORE hCertStore;
//PCCERT_CONTEXT pCertContext = NULL;
CERT_ENHKEY_USAGE EnhkeyUsage;
CERT_USAGE_MATCH CertUsage;
CERT_CHAIN_PARA ChainPara;
DWORD dwFlags = 0;
//LPWSTR pszNameString;
//---------------------------------------------------------
// Initialize data structures.
EnhkeyUsage.cUsageIdentifier = 0;
EnhkeyUsage.rgpszUsageIdentifier = NULL;
CertUsage.dwType = USAGE_MATCH_TYPE_AND;
CertUsage.Usage = EnhkeyUsage;
ChainPara.cbSize = sizeof(CERT_CHAIN_PARA);
ChainPara.RequestedUsage = CertUsage;
ChainConfig.cbSize = sizeof(CERT_CHAIN_ENGINE_CONFIG) * 4;
ChainConfig.hRestrictedRoot = NULL;
ChainConfig.hRestrictedTrust = NULL;
ChainConfig.hRestrictedOther = NULL;
ChainConfig.cAdditionalStore = 0;
ChainConfig.rghAdditionalStore = nullptr;
ChainConfig.dwFlags = CERT_CHAIN_CACHE_END_CERT;
ChainConfig.dwUrlRetrievalTimeout = 0;
ChainConfig.MaximumCachedCertificates = 0;
ChainConfig.CycleDetectionModulus = 0;
ChainConfig.hExclusiveRoot = NULL;
ChainConfig.hExclusiveTrustedPeople = NULL;
ChainConfig.dwExclusiveFlags = 0;
//---------------------------------------------------------
// Create the non default certificate chain engine.
if (!CertCreateCertificateChainEngine(
&ChainConfig,
&hChainEngine))
{
DWORD err = GetLastError();
MessageBox(NULL, L"The engine creation function failed.", L"Error ", MB_OK);
return false;
}
我也看到这个post:
similar problem
and other
但我找不到解决方案。
我找到了解决方案。
在项目属性页面中,我将平台工具集更改为:
我使用 visual studio 2013 和 windows 7 32 位。
我想通过根证书和证书链验证数字签名。
所以我在 certcreatecertificatchainengine() 中得到 0x80070057 错误代码。
bool result = false;
HCERTCHAINENGINE hChainEngine;
CERT_CHAIN_ENGINE_CONFIG ChainConfig;
PCCERT_CHAIN_CONTEXT pChainContext;
//PCCERT_CHAIN_CONTEXT pDupContext;
HCERTSTORE hCertStore;
//PCCERT_CONTEXT pCertContext = NULL;
CERT_ENHKEY_USAGE EnhkeyUsage;
CERT_USAGE_MATCH CertUsage;
CERT_CHAIN_PARA ChainPara;
DWORD dwFlags = 0;
//LPWSTR pszNameString;
//---------------------------------------------------------
// Initialize data structures.
EnhkeyUsage.cUsageIdentifier = 0;
EnhkeyUsage.rgpszUsageIdentifier = NULL;
CertUsage.dwType = USAGE_MATCH_TYPE_AND;
CertUsage.Usage = EnhkeyUsage;
ChainPara.cbSize = sizeof(CERT_CHAIN_PARA);
ChainPara.RequestedUsage = CertUsage;
ChainConfig.cbSize = sizeof(CERT_CHAIN_ENGINE_CONFIG) * 4;
ChainConfig.hRestrictedRoot = NULL;
ChainConfig.hRestrictedTrust = NULL;
ChainConfig.hRestrictedOther = NULL;
ChainConfig.cAdditionalStore = 0;
ChainConfig.rghAdditionalStore = nullptr;
ChainConfig.dwFlags = CERT_CHAIN_CACHE_END_CERT;
ChainConfig.dwUrlRetrievalTimeout = 0;
ChainConfig.MaximumCachedCertificates = 0;
ChainConfig.CycleDetectionModulus = 0;
ChainConfig.hExclusiveRoot = NULL;
ChainConfig.hExclusiveTrustedPeople = NULL;
ChainConfig.dwExclusiveFlags = 0;
//---------------------------------------------------------
// Create the non default certificate chain engine.
if (!CertCreateCertificateChainEngine(
&ChainConfig,
&hChainEngine))
{
DWORD err = GetLastError();
MessageBox(NULL, L"The engine creation function failed.", L"Error ", MB_OK);
return false;
}
我也看到这个post:
similar problem
and other
但我找不到解决方案。
我找到了解决方案。
在项目属性页面中,我将平台工具集更改为: