使用 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/