【问题标题】:CertCreateCertificateChainEngine throws an error in windows 7CertCreateCertificateChainEngine 在 Windows 7 中引发错误
【发布时间】:2017-09-27 12:43:37
【问题描述】:
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) 参数不正确,有人可以帮忙吗?

【问题讨论】:

  • 我只是偶然发现了同样的问题。我已经搜索并尝试了许多示例,但没有任何效果。你 5 个月前问过这个问题。你知道答案吗,请告诉我?

标签: windows cryptography cryptoapi windows-api-code-pack


【解决方案1】:

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

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

您可以将它们设置为 NULL(如果您不需要它们)来处理错误:

ChainConfig.hExclusiveRoot = NULL;
ChainConfig.hExclusiveTrustedPeople = NULL;

【讨论】:

  • 我使用的是 Windows 7,但没有任何效果。我也得到 0x80070057。你能写一个有效的例子吗?
  • @QuangNHb 您可能需要设置程序以针对正确的平台;这里有几个答案可能会对您有所帮助:Answer 1, Answer 2
  • @frislm 感谢您回答我。我使用 windows 7 和 Visual Studio 2015 进行编译。我不想在 Windows XP 上运行程序。 _WIN32_WINNT 等于 0x0601。
猜你喜欢
  • 2016-04-26
  • 1970-01-01
  • 2011-05-09
  • 1970-01-01
  • 2012-03-05
  • 1970-01-01
  • 2015-07-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多