由于私钥过滤器,signtool 无法在 Windows 10 上找到证书

signtool fails to find certificate on Windows 10, due to private key filter

我是 UniversalADBDriver 的开发者,这是一种在用户计算机上创建自签名 Android USB 驱动程序的工具。

安装程序和安装包的源代码: https://github.com/koush/UniversalAdbDriver

该工具生成一个密钥对并将证书添加到用户的密钥库,然后签署驱动程序文件。在 Windows 10 之前,它工作正常,它莫名其妙地停止工作。我运行手动命令行:

The following certificates were considered:
    Issued to: UniversalADB
    Issued by: UniversalADB
    Expires:   Fri Aug 25 17:00:00 2017
    SHA1 hash: C8701DF4CDC7DD75813400AD2B3B4C2EFDA4E662

After EKU filter, 1 certs were left.
After expiry filter, 1 certs were left.
After Private Key filter, 0 certs were left.
SignTool Error: No certificates were found that met all the given criteria.

在 Windows 10,证书被 "Private Key filter" 过滤掉。不知道那是什么,上面没有任何文档。

更新

我发现在 Windows 10 上通过安装程序调用时,makecert.exe 或 X509Store.add 都不能将 certificates/keys 写入当前用户存储。但是,本地计算机存储中的证书放置正确。我不确定为什么会这样。所以基本上,私钥没有正确放置在商店中,因此签名失败。 运行 在命令行上手动执行相同的步骤。然而,我仍然需要弄清楚为什么私钥没有保存在商店中。

我使用 BouncyCastle 以编程方式生成证书。出于某种原因,此证书似乎在 Windows 10 上不再有效。我切换到打包 makecert.exe 来生成证书,这似乎解决了问题。