3
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;

//---------------------------------------------------------
// Create the nondefault certificate chain engine.
if (CertCreateCertificateChainEngine(
        &ChainConfig,
        &hChainEngine)){
        printf("A chain engine has been created.\n");}

Getting error 0x80070057 (-2147024809) The parameter is incorrect, can someone help here ?

  • I just stumbled upon the same issue. I have searched and tried many examples and nothing works. You asked this question 5 months ago. Do you know the answer, please tell me? – QuangNHb Mar 04 '18 at 17:29

1 Answers1

1

I hope you've managed to solve this issue already. If not, here's my somewhat late answer:

It looks like you're working with Microsoft's example code for creating a certificate chain. Unfortunately it seems to be out of date; if you examine the documentation for CERT_CHAIN_ENGINE_CONFIG, you'll see that there are two more member variables that need to be initialized in Windows 7, hExclusiveRoot and hExclusiveTrustedPeople.

You could set them to NULL (if you don't need them) to take care of the error:

ChainConfig.hExclusiveRoot = NULL;
ChainConfig.hExclusiveTrustedPeople = NULL;
frslm
  • 2,969
  • 3
  • 13
  • 26
  • I use windows 7 and nothing works.I get 0x80070057, too. May you write a working example? – QuangNHb Mar 04 '18 at 17:32
  • @QuangNHb You may need to set up your program to target the correct platform; here are a couple answers that might help you out: [Answer 1](https://stackoverflow.com/questions/34313023/i-get-0x80070057-error-code-on-certcreatecertificatechainengine-func/34480267#34480267), [Answer 2](https://stackoverflow.com/questions/6429251/vs2010-structure-change-in-cryptoapi-v7-0a-vs-v6-0a-wincrypt-h/6549295#6549295) – frslm Mar 05 '18 at 17:26
  • @frislm Thank for answering me. I use windows 7 and Visual Studio 2015 to compile. I don't want to run program on windows XP. _WIN32_WINNT is equal to 0x0601. – QuangNHb Mar 09 '18 at 18:23