小编mir*_*cea的帖子

在C#中对文件进行数字签名时如何添加时间戳?

我尝试在.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和系统的当前时间.对于时间服务器,它可能更复杂,因为时间服务器有自己的证书,答案将包含时间和用作签名的哈希.

任何人都可以提供一些线索吗?

.net c# cryptography digital-signature

8
推荐指数
1
解决办法
2472
查看次数

标签 统计

.net ×1

c# ×1

cryptography ×1

digital-signature ×1