Can we have the option of not canonicalising the signed XML file?

Ian Young ian at iay.org.uk
Tue Sep 29 08:44:30 UTC 2020



> On 2020-09-29, at 03:13, Weiwu Zhang via dev <dev at shibboleth.net> wrote:
> 
> 
> If I undrestood XMLDSIG correctly, the signature is applied on the digest of the node, which is canonicalised, but it doesn't have to be enveloped in a canonicalised file.

True as far as it goes: a signature can be enveloped (the thing that XMLSecTool supports, and the only one relevant to our use cases), enveloping or detached (an entirely independent blob).


> That is, it should be possible to append signature to an XML without changing other parts of the XML file at all and it would still be valid.

An XML document has only one element at the top level (the document element). It is invalid to drop another XML blob in after the document element. The closest you can get in a single document is an enveloped signature with the signature blob dropped in as the last child of the document element.

XMLSecTool actually theoretically supports that using the following option:

	--signaturePosition LAST

This isn't used in SAML, though, so this option may not have been well tested.


> This is important in the case the XML file needs to be viewed or, that it contains errors that can only be captured at run time, and not schema-detectable - in our use-case, you need blockchain data to figure out if there is an error in an XML file that describes a blockchain token.
> 
> In such cases, it's important to report a line number of the error that the developers can use to trace in their original, unsigned XML file.
> 
> If such an option is possible, I actually feel it should be the default. XML use-cases are already complicated and having to deal with the canonicalised form is another burden on the learning curve. Making it transparent is one less things to keep in mind for the developers. Besides, why would enveloped and external xmldsig be any different (where the external one didn't require you to change the file structure, but the enveloped one resulted in dramatically changed canonicalised form).

Putting a detached signature inside the original file is, by definition, not possible.

XMLSecTool doesn't support either the generation or the validation of detached signatures. You could submit a JIRA issue proposing an enhancement, but I have to be honest that unless that request came from a consortium member, we'd be fairly unlikely to work on something that wasn't needed for our members' use cases: the only XML-based signable documents we work with tend to be SAML metadata, and the SAML profiles are very particular about what is required. The other relevant protocols and formats tend to be JSON-based and of course XMLSecTool doesn't address those use cases.

    -- Ian




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20200929/482bdd21/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3883 bytes
Desc: not available
URL: <http://shibboleth.net/pipermail/dev/attachments/20200929/482bdd21/attachment.p7s>


More information about the dev mailing list