使用 mage.exe 在单独的机器上签名和时间戳清单文件

问题描述

我的用例是这样的:我希望能够在“气隙”计算机上签署 EXE 和清单,然后在连接互联网的计算机上添加时间戳:

enter image description here

这在 signtool.exe 中是可行的。我遇到的问题是 mage.exe。它似乎无法单独签署然后为签名加上时间戳,这似乎很奇怪。

我尝试了以下方法

mage.exe -Sign "myapp.exe.manifest" -CertHash %HASH%
mage.exe -Update "myapp.exe.manifest" -Timestampuri http://timestamp.comodoca.com

在签名步骤之后,我可以检查清单并清楚地看到它已被签名。 但是,更新步骤会完全删除签名。

如果我这样做

mage.exe -Sign "myapp.exe.manifest" -CertHash %HASH% -Timestampuri http://timestamp.comodoca.com

它工作正常,清单已签名并带有时间戳

签名清单和签名加时间戳清单之间的唯一区别,不出所料,就是时间戳信息。

那么,问题是,是否可以使用 mage.exe 对清单进行签名,然后以 signtool.exe 允许的方式添加时间戳?

非常感谢, 詹姆斯

编辑:我还没有尝试但会做的一件事是...... 如果 signtool.exe 可以单独执行此操作,大概它不需要用于对二进制文件进行签名的原始私钥,因此这意味着时间戳不需要私钥,我认为这是有道理的,因为时间戳是“冻结”数字签名,只有公共证书,所以我可以自己生成并手动将其添加到清单中吗?

解决方法

时间戳是您文件的一部分,当您添加时间戳时:

->文件内容改变了,

->更改文件签名

->您必须退出您的应用程序。

  1. 什么是“标志”
    digest_fun(file_to_sign) -> publisher_digest_of_file
    sign_fun(publisher_digest_of_file,private_key) -> publisher_signature
  1. 如何验证“签名”
    digest_fun(file_to_sign) -> digest_of_file
    sign_fun(publisher_signature,public_key) -> publisher_digest_of_file
    assert_fun(digest_of_file == publisher_digest_of_file)
    //if anyone change the content of the file,it fails
  1. “时间戳+符号”的作用
    digest_fun(file_to_sign + timestamp) -> publisher_digest_of_file_and_timestamp
    sign_fun(publisher_digest_of_file_and_timestamp,private_key) -> publisher_signature
  1. 如何验证“时间戳+符号”
    digest_fun(file_to_sign + timestamp) -> digest_of_file_and_timestamp
    sign_fun(publisher_signature,public_key) -> publisher_digest_of_file_and_timestamp
    assert(digest_of_file_and_timestamp == publisher_digest_of_file_and_timestamp)
    //if anyone change the content of the file,it fails
    //if anyone change the timestamp,it fails

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...