XmlDSig Error: "Did not find same-document Reference Id"
The Chilkat error message
XmlDSig Error: "Did not find same-document Reference Id"
means that during XML Digital Signature verification or creation, Chilkat could not find the element within the same XML document that corresponds to the Reference element’s URI (usually an internal fragment identifier, like #id123).
What It Means
In XMLDSig, each <Reference> in <SignedInfo> specifies what part of the document is being signed.
For example:
<Reference URI="#invoice123">
<Transforms>...</Transforms>
<DigestMethod Algorithm="..."/>
<DigestValue>...</DigestValue>
</Reference>
Chilkat then looks for an element in the same XML document with:
<SomeElement Id="invoice123"> ... </SomeElement>
If it can’t find that element — i.e., there’s no element with a matching Id, ID, or xml:id attribute — it throws:
"Did not find same-document Reference Id"
Common Causes
- The referenced
Idattribute is missing.- Example:
<Invoice>exists, but doesn’t haveId="invoice123".
- Example:
- The attribute name doesn’t match exactly.
- Chilkat recognizes
Id,ID, orxml:idas valid XML ID attributes. - But if your element uses
id="..."(lowercase) and your XML doesn’t declare it as typeID, Chilkat won’t find it.
- Chilkat recognizes
- The
ReferenceURI is empty or malformed.URI=""means the entire document is signed.- If the URI starts with
#, Chilkat expects a same-document element with a matching ID.
- Namespaces or canonicalization altered the attribute.
- If the XML was transformed (e.g., enveloped signature), the
Idmight have been stripped or moved.
- If the XML was transformed (e.g., enveloped signature), the