Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the QualifyingProperties Target #134

Open
shunkica opened this issue Jun 13, 2023 · 0 comments
Open

Change the QualifyingProperties Target #134

shunkica opened this issue Jun 13, 2023 · 0 comments

Comments

@shunkica
Copy link

shunkica commented Jun 13, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant