Skip to content

Cloning a package breaks digital signatures. #1357

@petarpetrovt

Description

@petarpetrovt

Describe the bug
Cloning a package via OpenXmlPackage Clone(Stream stream) method breaks digital signatures.

Screenshots
documentrels
rels

To Reproduce

using var document = WordprocessingDocument.Open("valid.docx", isEditable: false);
using var clonedStream = File.Open("invalid.docx", FileMode.Create, FileAccess.ReadWrite);
using var clone = document.Clone(clonedStream);

Steps to reproduce the behavior:

  1. Create .docx file using Microsoft Word and add digital signature or signature line and sign it.
  2. Open via WordprocessingDocument and Clone into new file.

Observed behavior
Some XML parts gets reordered, / added to Target attribute in Relationship URIs, standalone XML declaration is added some parts.

Expected behavior
No changes should happen in part that are used in signature digests.

Desktop (please complete the following information):

  • OS: Windows
  • .NET Target: net6.0
  • DocumentFormat.OpenXml Version: 2.19.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions