对任意数量、任意格式的文件进行签名的另一种标准化方法是使用单独的目录文件 (.cat)。这通常用于对驱动程序进行签名,但也用于某些 Microsoft 发布的 ISO。
你得到什么
如何创建
为此,您需要 Powershell 和要签名的文件(或文件目录)。
假设您要签名的文件名为 A ZipFile.zip。运行以下命令
New-FileCatalog -Path AZipFile.zip -CatalogFilePath myCatalog.cat -CatalogVersion 2.0
这将创建一个目录文件,但没有签名。Image https://i.stack.imgur.com/T7f5l.jpg
运行以下命令来添加签名。需要时间戳服务器,以便签名证书过期后签名仍然有效。代替Cert:\CurrentUser\My\18daf8ffb3dc9d84903a9eb65fb8a1970ceb7139
以及您的证书的路径
Set-AuthenticodeSignature -FilePath myCatalog.cat -Certificate (Get-Item Cert:\CurrentUser\My\18daf8ffb3dc9d84903a9eb65fb8a1970ceb7139) -TimestampServer http://timestamp.comodoca.com
现在目录文件显示了有效的签名。Image https://i.stack.imgur.com/4YHI0.jpg
如何验证
通过双击 Windows 上的目录文件,您可以查看签名是否有效,以及文件及其哈希值的列表。但是,GUI 无法帮助您验证文件。为此,您需要另一个 powershell 命令。
Test-FileCatalog -CatalogFilePath myCatalog.cat -Path AZipFile.zip
如果目录下所有文件的签名有效,则返回Valid
.