简体   繁体   English

使用C#在.docx中进行数字签名信息

[英]Digital signature informations in .docx with C#

I'm working with .docx files in my application via DocX library which I use to edit some parts of document and parse templates. 我正在通过DocX库在我的应用程序中使用.docx文件,我用它来编辑文档的某些部分并解析模板。 My problem is when client digitally sign document, I don't know how to get informations about signature. 我的问题是当客户端对文档进行数字签名时,我不知道如何获取有关签名的信息。 I need to check who signed document. 我需要查看谁签署了文件。

I think that DocX library doesn't provide me with that informations, or I couldn't figure it out where to find them. 我认为DocX库没有向我提供这些信息,或者我无法弄清楚在哪里找到它们。

Any other suggestions will be most appreciated. 任何其他建议将非常感谢。

I've spent couple of days in research and find out that you could read document signature with: System.IO.Packages -> PackageDigitalSignatureManager link 我花了几天时间研究并发现你可以阅读文档签名: System.IO.Packages -> PackageDigitalSignatureManager link

Package pkg = Package.Open(documentStream, FileMode.Open, FileAccess.ReadWrite);

PackageDigitalSignatureManager dsm =
                new PackageDigitalSignatureManager(pkg);

where doucumentStream is MemoryStream of your file. 其中doucumentStream是您文件的MemoryStream

Then you can check if file is digitally signed, verify that signature, or get details about that signature (who, where, why). 然后,您可以检查文件是否经过数字签名,验证签名,或获取有关该签名的详细信息(谁,地点,原因)。

dsm.IsSigned ...
dsm.VeryfySignature() ...
dsm.Signatures ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM