freshbm
freshbm

Reputation: 5622

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. 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.

Any other suggestions will be most appreciated.

Upvotes: 2

Views: 2150

Answers (1)

freshbm
freshbm

Reputation: 5622

I've spent couple of days in research and find out that you could read document signature with: 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.

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 ...

Upvotes: 4

Related Questions