Windows 更新驱动程序以使用 VS2019 / WDK 22000 构建后,MS 签名的过滤器驱动程序不会在 Win 7 x64 上加载

Windows MS signed filter driver doesn't load on Win 7 x64 after updating driver to build with VS2019 / WDK 22000

我最近接受了一项任务,从 Visual Studio 2015 -> 2019 构建更新我们的过滤器驱动程序。我还转移到最新的 SDK + WDK 22000(这是新的 Windows 11一个).

除了在 Win 7 x64(使用安全启动)框上驱动程序不再加载外,一切似乎都正常工作。它得到:

Load failed with error: 0x80070241
Windows cannot verify the digital signature for this file. A recent hardware or
software change might have installed a file that is signed incorrectly or damaged,
or that might be malicious software from an unknown source.

我们的驱动程序 was/is 由 Microsoft 通过 MS 硬件门户签署的证明,因此它由我们公司和 Microsoft 共同签署,各自具有 SHA-2 签名。 Windows 7 不支持开箱即用的 SHA-2 证书,但是,它以前可以工作,前提是:

Windows6.1-KB3033929-x64

已安装。不过似乎有些事情发生了变化,Windows 7 x64 boxes 即使有最新的更新也无法加载新的驱动程序。他们可以很好地加载 2015 年构建的驱动程序,即使 上的证书看起来 相同。新驱动程序在 Windows 10 台机器上加载得很好。

是否有人知道可能导致此组合无法加载的任何其他更改?

几个月前我遇到了类似的问题,当时我们决定更换我们的证书提供商。我会把我的知识分享给你,希望能对你有所帮助。

不久前,Microsoft 使用交叉证书来验证受信任的证书颁发机构 (CA),因此您唯一需要签署驱动程序的是从受信任的 CA 购买的适当证书。但是 recently 验证过程已更改,从 Windows 10 20H2 开始,您被迫通过 Microsoft 合作伙伴中心签署您的驱动程序,并且所有交叉证书均已弃用。但是,您仍然需要在 Windows 10 之前对所有驱动程序使用交叉签名过程,实际上交叉签名的驱动程序将工作到 Windows 10 20H1 如果正确。

现在回到Visual Studio。要正确签署驱动程序,您必须将生产证书设置为字段 Properties -> Driver Signing -> General -> Production Certificate,这会导致 Visual Studio 使用 signtool 实用程序在构建完成后签署驱动程序。据我推测,Visual Studio 2019 流程不使用交叉证书,看起来像:

signtool sign /v <trusted_certificate> /tr http://timestamp.digicert.com /td sha256 /fd sha256 /a <sys_driver_filepath>

但是Visual Studio2013其实必须使用交叉证书,它使用的命令是:

signtool sign /v /ac <microsoft_cross_certificate> /tr http://timestamp.digicert.com /a <sys_driver_filepath>

那么什么是交叉证书呢?它是一种特殊的受信任的 Microsoft 证书,与经过认证的 CA 相关联。可以在此处找到所有可用交叉证书的列表 https://docs.microsoft.com/en-us/windows-hardware/drivers/install/cross-certificates-for-kernel-mode-code-signing#cross-certificate-list. To take the correct one you need to check your company certificate first. Take a look into root of certification path of your cert, open View Properties -> Details and find Issuer, that's your CA. Now you need to find exact match on cross-certificate list and download it. Note the thumbprint doesn't need to match (revealed in )。毕竟使用正确的 signtool 命令来签署您的文件。

P.S. 如果您的证书颁发者不在列表中,这意味着您的 CA 不合适,您需要 get/buy 另一个证书。