问题
I use visual studio 2013 and windows 7 32bit.
I want to verify digital signature by root and chain of certificate.
So I get 0x80070057 error code in certcreatecertificatechainengine().
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;
}
Also I see this post:
similar problem
and other
but I can not find solution.
回答1:
I found the solution.
In the project property page, I change the platform toolset to:
来源:https://stackoverflow.com/questions/34313023/i-get-0x80070057-error-code-on-certcreatecertificatechainengine-func