我尝试在.NET C#中实现类似于signtool.exe的实用程序.为了对文件进行数字签名,我使用了SignedCms和CmsSigner类.
CmsSigner signer;
...
SignedCms content =
new SignedCms(new ContentInfo(File.ReadAllBytes(aFileToSign)));
content.ComputeSignature(signer, true);
Run Code Online (Sandbox Code Playgroud)
但是,我不确定如何添加从时间服务器收到的时间戳.signtool.exe有选项
signtool sign /t "time server url" ...
Run Code Online (Sandbox Code Playgroud)
一种可能性似乎是使用Pkcs9SigningTime类,但我不知道如何正确使用它与时间戳服务器.所有示例都使用Pkcs9SigningTime和系统的当前时间.对于时间服务器,它可能更复杂,因为时间服务器有自己的证书,答案将包含时间和用作签名的哈希.
任何人都可以提供一些线索吗?