Digitally (fully) sign a Package (eg. docx or xlsx) RRS feed

  • Question

  • As we have seen here: 

    it is reasonably easy to sign a document package. However if I do this with my example .docx document, I always receive a "partly signed" document. In comparison, if I sign the document with Word itself.... next time opened, it shows "fully/completely signed" with signature Xxxx Xxxx. This confuses users and maybe it is even just a very unimportant part, that is signed. 

    What went wrong? I want a completely signed document.

    Here is my working example:

                using (var wd = WordprocessingDocument.Open(ofd.FileName, true))
                    Package wdPackage = wd.Package;
                    List<Uri> packageParts2sgn = wdPackage.GetParts().ToList()
                            .Where(part => !PackUriHelper.IsRelationshipPartUri(part.Uri))
                            .Select(p => p.Uri)
                        PackageDigitalSignatureManager dsm = new PackageDigitalSignatureManager(wdPackage);
                        PackageRelationshipCollection relationships = wdPackage.GetRelationships();
                        List<PackageRelationshipSelector> relShipSelectors = relationships.Select(
                                    rl =>
                                        new PackageRelationshipSelector(
                        X509Store store = new X509Store(StoreLocation.CurrentUser);
                        X509Certificate2Collection collection = store.Certificates.Find(X509FindType.FindBySerialNumber,"600d923c00010014444e",true);
                        var certificate = collection[0];
                        dsm.CertificateOption = CertificateEmbeddingOption.InSignaturePart;
                        dsm.Sign(packageParts2sgn, certificate, relShipSelectors);

    Tuesday, October 11, 2016 3:44 PM

All replies

  • Hi Robert0K,

    Since this issue is complex, I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Wednesday, October 12, 2016 9:23 AM