windows - Set-AuthenticodeSignature 不会执行 SHA256 时间戳?

标签 windows powershell code-signing authenticode

使用 Visual Studio 2019 Community 对服务器核心 Windows Server 2019 Datacenter Edition 上的 Windows 二进制文件进行签名。 signtool.exe 行为不正确(打开 PFX 文件时出现问题),因此建议我们切换到 PowerShell + Set-AuthenticodeSignature

使用以下命令:

$securepassword = ConvertTo-SecureString -String $password -AsPlainText -Force

$pfx = Get-PfxData -FilePath $certificate -Password $securepassword
$cert = $pfx.EndEntityCertificates[0]

Set-AuthenticodeSignature -FilePath $target -Certificate $cert -HashAlgorithm "SHA256" -TimestampServer http://timestamp.digicert.com

生成具有预期 SHA256 签名的二进制文件,但时间戳签名是 SHA1。还尝试使用 http://timestamp.digicert.com?alg=sha256 作为服务器,但是 Set-AuthenticodeSignature 根本不添加时间戳签名。

由于该命令不允许您指定时间戳算法的哈希值,我们如何实现这一点?

最佳答案

使用另一个 RFC3161 时间戳服务器。例如:

-TimestampServer“http://timestamp.comodoca.com/rfc3161”

当我尝试在 PowerShell 中使用 -TimestampServer "http://timestamp.digicert.com?alg=sha256" 时,我也在 Windows 10 Enterprise 中看到此问题,尽管此时间戳服务器可以正常工作同一环境中的signtool。

如果刷新本地 DNS 缓存,然后使用 Wireshark 观察网络接口(interface),signtool 和 Set-AuthenticodeSignature 通常都会在签名过程中触发对时间戳服务器的 DNS 查找。将 DigiCert URL 与 Set-AuthenticodeSignature 一起使用时,不会发生这种情况。该 cmdlet 似乎可能存在 ?alg=sha256 参数问题,然后完全跳过时间戳步骤。

关于windows - Set-AuthenticodeSignature 不会执行 SHA256 时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60235050/

相关文章:

javascript - 我的 p5.js Canvas 窗口随着每次代码执行而不断变化。我怎样才能阻止这个?

python - 将 Python 嵌入到 C 中

c++ - GetShortPathName 不可预测的结果

date - 比较没有时间的日期

windows - 为什么段虚拟地址需要连续?

powershell - 相同的数组内容,给我不同的结果

powershell - 根据文件名中间的版本号对文件进行排序

certificate - 制作自己的文件签名证书?

windows-phone-8 - "Can' t 在 Windows Phone 8 上安装公司应用程序

ios - 由于代码签名错误而终止