Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/signed-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,29 @@ export class SignedXml {
}

private getCanonReferenceXml(doc: Document, ref: Reference, node: Node) {
const transforms: string[] = [];

/**
* Search for ancestor namespaces before canonicalization.
*/
if (Array.isArray(ref.transforms)) {
transforms.push(...ref.transforms);
ref.ancestorNamespaces = utils.findAncestorNs(doc, ref.xpath, this.namespaceResolver);
}

const c14nOptions = {
inclusiveNamespacesPrefixList: ref.inclusiveNamespacesPrefixList,
ancestorNamespaces: ref.ancestorNamespaces,
};

if (
transforms.length === 0 ||
transforms[transforms.length - 1] === "http://www.w3.org/2000/09/xmldsig#enveloped-signature"
) {
transforms.push("http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't exclusive C14N be more compatible?

transforms.push("http://www.w3.org/2001/10/xml-exc-c14n#");

}

return this.getCanonXml(ref.transforms, node, c14nOptions);
return this.getCanonXml(transforms, node, c14nOptions);
}

private calculateSignatureValue(doc: Document, callback?: ErrorFirstCallback<string>) {
Expand Down