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

Set-AuthenticodeSignature won't perform SHA256 Timestamp?

使用 Visual Studio 2019 社区在 Server Core 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 观察网络接口,signtool 和 Set-AuthenticodeSignature 通常会在签名过程中触发时间戳服务器的 DNS 查找。使用 DigiCert URL 和 Set-AuthenticodeSignature 时不会发生这种情况。该 cmdlet 似乎可能与 ?alg=sha256 参数有关,然后完全跳过时间戳步骤。