Describe the issue
The System Application SignedXml codeunit cannot load or verify otherwise valid XMLDSIG/XAdES signatures that use the W3C XPath Filter 2.0 transform:
http://www.w3.org/2002/06/xmldsig-filter2
Calling:
SignedXml.LoadXml(SignatureElement);
for such a signature fails with:
Unknown transform has been encountered.
This transform is used by real-world XAdES signed business documents.
In our interoperability corpus, XAdES signatures using only the standard enveloped-signature transform can be successfully loaded and verified using Business Central SignedXml, while valid XAdES signatures using XPath Filter 2.0 fail during LoadXml.
This prevents extensions from verifying these signatures through the public System Application XML signature API.
Expected behavior
SignedXml should support loading and verifying XMLDSIG references that use the XPath Filter 2.0 transform:
http://www.w3.org/2002/06/xmldsig-filter2
Alternatively, the public API should provide an extensibility mechanism that allows additional XMLDSIG transforms to be registered or supplied by extensions.
The latter could also make the API more future-proof for other standardized XMLDSIG transforms that are not directly implemented by the current wrapper.
Steps to reproduce
-
Obtain or construct an XML digital signature containing a reference with:
<ds:Transform Algorithm="http://www.w3.org/2002/06/xmldsig-filter2">
-
Load the XML document in AL.
-
Locate the ds:Signature element.
-
Initialize the System Application SignedXml codeunit:
SignedXml.InitializeSignedXml(XmlDocument);
-
Call:
SignedXml.LoadXml(SignatureElement);
-
Observe that the call fails with:
Unknown transform has been encountered.
The same code succeeds for comparable XML signatures that use supported transforms such as:
http://www.w3.org/2000/09/xmldsig#enveloped-signature
Additional context
Our immediate use case is generic XAdES verification in Business Central.
We tested a real-world set of electronic business documents and found multiple structurally valid XAdES signatures using XPath Filter 2.0. These cannot currently be verified using the public SignedXml API because LoadXml rejects the transform before signature verification can take place.
This is distinct from the previously reported issues regarding:
- setting
Reference.Type for XAdES SignedProperties;
- accessing pre-sign/canonicalized
SignedInfo for external signing.
Those affect XAdES creation and external signing. This issue affects verification of existing signatures.
Supporting XPath Filter 2.0, or allowing additional XMLDSIG transforms to be registered with SignedXml, would improve interoperability without requiring consuming extensions to implement their own XML canonicalization and XMLDSIG verification engine.
We would be willing to contribute tests and, where feasible, implementation work if the required underlying transform support can be exposed through System Application.
Additional upstream runtime context
This limitation also exists in the underlying .NET System.Security.Cryptography.Xml.SignedXml implementation.
The dotnet/runtime repository tracks the same interoperability problem in:
** dotnet/runtime#82363: “SignedXml cannot validate signature that contain XPath transforms”**
The reproducer in that issue is an XAdES signature using the same standardized transform:
http://www.w3.org/2002/06/xmldsig-filter2
Therefore, this may currently be an upstream runtime limitation rather than solely a missing Business Central wrapper API.
If XPath Filter 2.0 support is added to System.Security.Cryptography.Xml in the future, it would be valuable for the Business Central System Application SignedXml abstraction to inherit or expose that capability without requiring changes in consuming AL extensions.
In the meantime, if Business Central has access to any lower-level platform implementation of the transform, exposing it through SignedXml would avoid requiring AL extensions to independently implement XPath Filter 2.0 node-set processing and XML canonicalization.
Alternatively, exposing a general transform-registration/extensibility mechanism could allow additional standardized XMLDSIG transforms to be supported without requiring a new System Application API for every transform.
I will provide a fix for a bug
Describe the issue
The System Application
SignedXmlcodeunit cannot load or verify otherwise valid XMLDSIG/XAdES signatures that use the W3C XPath Filter 2.0 transform:Calling:
for such a signature fails with:
This transform is used by real-world XAdES signed business documents.
In our interoperability corpus, XAdES signatures using only the standard enveloped-signature transform can be successfully loaded and verified using Business Central
SignedXml, while valid XAdES signatures using XPath Filter 2.0 fail duringLoadXml.This prevents extensions from verifying these signatures through the public System Application XML signature API.
Expected behavior
SignedXmlshould support loading and verifying XMLDSIG references that use the XPath Filter 2.0 transform:Alternatively, the public API should provide an extensibility mechanism that allows additional XMLDSIG transforms to be registered or supplied by extensions.
The latter could also make the API more future-proof for other standardized XMLDSIG transforms that are not directly implemented by the current wrapper.
Steps to reproduce
Obtain or construct an XML digital signature containing a reference with:
Load the XML document in AL.
Locate the
ds:Signatureelement.Initialize the System Application
SignedXmlcodeunit:Call:
Observe that the call fails with:
The same code succeeds for comparable XML signatures that use supported transforms such as:
Additional context
Our immediate use case is generic XAdES verification in Business Central.
We tested a real-world set of electronic business documents and found multiple structurally valid XAdES signatures using XPath Filter 2.0. These cannot currently be verified using the public
SignedXmlAPI becauseLoadXmlrejects the transform before signature verification can take place.This is distinct from the previously reported issues regarding:
Reference.Typefor XAdESSignedProperties;SignedInfofor external signing.Those affect XAdES creation and external signing. This issue affects verification of existing signatures.
Supporting XPath Filter 2.0, or allowing additional XMLDSIG transforms to be registered with
SignedXml, would improve interoperability without requiring consuming extensions to implement their own XML canonicalization and XMLDSIG verification engine.We would be willing to contribute tests and, where feasible, implementation work if the required underlying transform support can be exposed through System Application.
Additional upstream runtime context
This limitation also exists in the underlying .NET
System.Security.Cryptography.Xml.SignedXmlimplementation.The dotnet/runtime repository tracks the same interoperability problem in:
** dotnet/runtime#82363: “SignedXml cannot validate signature that contain XPath transforms”**
The reproducer in that issue is an XAdES signature using the same standardized transform:
http://www.w3.org/2002/06/xmldsig-filter2Therefore, this may currently be an upstream runtime limitation rather than solely a missing Business Central wrapper API.
If XPath Filter 2.0 support is added to
System.Security.Cryptography.Xmlin the future, it would be valuable for the Business Central System ApplicationSignedXmlabstraction to inherit or expose that capability without requiring changes in consuming AL extensions.In the meantime, if Business Central has access to any lower-level platform implementation of the transform, exposing it through
SignedXmlwould avoid requiring AL extensions to independently implement XPath Filter 2.0 node-set processing and XML canonicalization.Alternatively, exposing a general transform-registration/extensibility mechanism could allow additional standardized XMLDSIG transforms to be supported without requiring a new System Application API for every transform.
I will provide a fix for a bug