2017-09-27 42 views
2
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");} 

获取错误0x80070057(-2147024809)参数不正确,有人可以帮忙吗?CertCreateCertificateChainEngine在Windows 7中引发错误

+0

我只是偶然发现了同样的问题。我搜索并尝试了很多例子,没有任何作品。 5个月前你问过这个问题。你知道答案,请告诉我吗? – QuangNHb

回答

0

我希望你已经设法解决这个问题了。如果没有,这里是我的回答:

看起来您正在使用微软的example code创建证书链。不幸的是,它似乎已经过时了;如果您查看CERT_CHAIN_ENGINE_CONFIG的文档,则会看到在Windows 7,hExclusiveRoothExclusiveTrustedPeople中还有两个需要初始化的成员变量。

你可以将它们设置为NULL(如果你不需要他们)采取错误的护理:

ChainConfig.hExclusiveRoot = NULL; 
ChainConfig.hExclusiveTrustedPeople = NULL; 
+0

我使用Windows 7并没有任何作品。我也得到0x80070057。你可以写一个工作的例子吗? – QuangNHb

+0

@QuangNHb你可能需要设置你的程序来定位正确的平台;这里有几个答案,可能会帮助你: [答案1](https://stackoverflow.com/questions/34313023/i-get-0x80070057-error-code-on-certcreatecertificatechainengine-func/34480267#34480267), [回答2](https://stackoverflow.com/questions/6429251/vs2010-structure-change-in-cryptoapi-v7-0a-vs-v6-0a-wincrypt-h/6549295#6549295) – frslm

+0

@frislm谢谢回答我。我使用Windows 7和Visual Studio 2015进行编译。我不想在Windows XP上运行程序。 _WIN32_WINNT等于0x0601。 – QuangNHb