I get 0x80070057 error code on certcreatecertificatechainengine func

感情迁移 提交于 2020-01-03 21:02:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!