Skip to content

The namespace prefix 'ds' is not defined #6

@federico-66

Description

@federico-66

Hi,
I have problems validating the signature when there is an xpath transformation like this:

    XadesNet.Signature.Parameters.SignatureXPathExpression xp = new XadesNet.Signature.Parameters.SignatureXPathExpression();
    xp.Namespaces.Add("ds", "http://www.w3.org/2000/09/xmldsig#");
    xp.XPathExpression = "not(ancestor-or-self::ds:Signature)";
    @params.XPathTransformations.Add(xp);
<ds:Reference Id="Reference-2a7b6767-1fd1-41e4-9243-999f84db0698" URI="">
    <ds:Transforms>
        <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
                <ds:XPath>not(ancestor-or-self::ds:Signature)</ds:XPath>
            </ds:Transform>
    </ds:Transforms>
    <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
    <ds:DigestValue>c9Qnr5yGH/uhTpLnAE6R4Sp8B4tFmw+46++bb6dsujA=</ds:DigestValue>
</ds:Reference>

The following validation generates the error: "The namespace prefix 'ds' is not defined"

using (FileStream fs = new FileStream(signed_file, FileMode.Open)) {
    xadesService = new XadesNet.XadesService();
    _signatureDocument = xadesService.Load(fs)(0);
    XadesNet.Validation.ValidationResult result = xadesService.Validate(_signatureDocument);
    if (result.IsValid) {
        MessageBox.Show("Verification success.");
    } else {
        MessageBox.Show("Verification failed: " + result.Message);
    }
}

If validate the signed xml with third-party software, validation is ok

If remove the xpath transformation, validation is ok.

TIA

Metadata

Metadata

Assignees

No one assigned

    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