Search code examples
node.jsxmlxml-dsig

How to change canonicalization method


does anyone know how to change the CanonicalizationMethod property in xadesjs? I know it is using xmldsigjs underneath but I cannot find a solution to change it. I mean the CanonicalizationMethod for the whole SignedInfo property (not the transforms for the references). Currently (by default) I get a document that has CanonicalizationMethod set to C14N:

<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>

I want to change it to EXC-C14N:

<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />

Is it even possible?


Solution

  • Ok, I've found a solution. In case anybody needs it, you can directly assign it with:

    let signedXml = new XAdES.SignedXml();
    signedXml.XmlSignature.SignedInfo.CanonicalizationMethod.Algorithm = "http://www.w3.org/2001/10/xml-exc-c14n#";