{"record":{"id":"58ed12c5498cea49","repo":"dotnet/wpf","slug":"sr-requiredtagnotfound-template-requiredtagnotfound-arg","errorCode":null,"errorMessage":"SR.RequiredTagNotFound (template: RequiredTagNotFound, arg: signaturePropertyTag)","messagePattern":"SR\\.RequiredTagNotFound \\(template: RequiredTagNotFound, arg: signaturePropertyTag\\)","errorType":"exception","errorClass":"System.Xml.XmlException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs","lineNumber":193,"sourceCode":"                        }\n                    }\n                }\n                else\n                    //Expected <SignatureProperty> tag not found.\n                    //Look for end tag corresponding to </SignatureProperty> or \n                    //if these are other custom defined properties, then anything with\n                    //depth greater than 2 should be ignored as these can be nested elements.\n                    if (((string.Equals(signaturePropertyTag, reader.LocalName, StringComparison.Ordinal)\n                        && (reader.NodeType == XmlNodeType.EndElement)))\n                        || reader.Depth > 2)\n                        continue;\n                    else\n                        //If we find the end tag for </SignatureProperties> then we can stop parsing\n                        if ((string.Equals(signaturePropertiesTag, reader.LocalName, StringComparison.Ordinal)\n                        && (reader.NodeType == XmlNodeType.EndElement)))\n                            break;\n                        else\n                            throw new XmlException(SR.Format(SR.RequiredTagNotFound, signaturePropertyTag));\n            }\n\n            //We did find one or more <SignatureProperty> tags but there were none that\n            //defined the id attribute and target attribute and <SignatureTime> element tag correctly.\n            if(!signatureTimePropertyFound)\n                throw new XmlException(SR.PackageSignatureCorruption);\n\n            return signingTime;\n        }\n\n       \n        //-----------------------------------------------------------------------------\n        //\n        // Private Methods\n        //\n        //-----------------------------------------------------------------------------\n\n        /// <summary>","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs#L175-L211","documentation":"While scanning for the signing-time <SignatureProperty>, ParseSigningTime expects either that element or the closing </SignatureProperties> tag. Any other element name encountered triggers RequiredTagNotFound(signaturePropertyTag) — the signature XML lacks the required structure, so the signature is treated as invalid.","triggerScenarios":"Signature validation where, inside <SignatureProperties>, the reader hits a LocalName that is neither the expected <SignatureProperty> tag nor the </SignatureProperties> end element — e.g. an unknown nested element.","commonSituations":"Non-conformant signing tools inserting extra elements into SignatureProperties; hand-edited signature XML; schema drift between signature producer and this validator.","solutions":["Ensure <SignatureProperties> contains only conformant <SignatureProperty> elements","Regenerate the signature with a compliant tool to remove stray elements","Validate the signature part against the OPC/XML-DSig schema before relying on it","Catch XmlException during validation and handle the package as having an invalid signature"],"exampleFix":"// before\n<SignatureProperties>\n  <UnknownElement/> <!-- unexpected -->\n</SignatureProperties>\n// after\n<SignatureProperties>\n  <SignatureProperty Id=\"SignatureTime\" Target=\"#id1\">...</SignatureProperty>\n</SignatureProperties>","handlingStrategy":"try-catch","validationCode":"bool SignaturePropertiesConformant(XElement props) =>\n    props.Elements().All(e => e.Name.LocalName == \"SignatureProperty\");","typeGuard":null,"tryCatchPattern":"try { signingTime = ParseSigningTime(stream, signatureId); }\ncatch (XmlException ex) when (ex.Message.Contains(\"RequiredTagNotFound\")) { /* signature invalid: proceed as unsigned */ }","preventionTips":["Restrict <SignatureProperties> content to <SignatureProperty> children","Use compliant signing libraries only","Validate the whole signature XML against the OPC schema before trusting it"],"tags":["xml","digital-signature","missing-element"],"backgroundTag":"schema-validation-failed","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}