Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Change the QualifyingProperties Target  #134

@shunkica

Description

@shunkica

It appears the library is setting a randomly generated Id to the QualifyingPropertes Target attribute when SignedXml is constructed, and I do not see any way to change this.XmlSignature.Id before this happens.

export class SignedXml extends XmlDSigJs.SignedXml {

    constructor(node?: Document | Element) {
        super(node);

        this.CreateQualifyingProperties();
    }
    
    protected CreateQualifyingProperties() {
        if (this.Properties) {
            throw new XmlCore.XmlError(XmlCore.XE.XML_EXCEPTION, "Cannot create QualifyingProperties cause current signature has got one. You must create CounterSignature");
        }

        const rnd = XmlDSigJs.Application.crypto.getRandomValues(new Uint8Array(6)) as Uint8Array;
        const id = XmlCore.Convert.ToHex(rnd);

        this.XmlSignature.Id ||= `id-${id}`;
        const dataObject = new XAdES.DataObject();
        dataObject.QualifyingProperties.Target = `#${this.XmlSignature.Id}`;
        dataObject.QualifyingProperties.SignedProperties.Id ||= `xades-${this.XmlSignature.Id}`;

        this.properties = dataObject.QualifyingProperties;
        this.XmlSignature.ObjectList.Add(dataObject);
    }
    
}

Shouldn't this Id be the same as the Signature id set in SignedXml().Sign fourth parameter (OptionsXAdES)?

From XAdES spec:

4.2 The QualifyingProperties

The mandatory Target attribute refers to the XML signature with which the qualifying properties are associated.

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