dotnet/wpf · error · System.Xml.XmlException
SR.PackageSignatureCorruption
Error message
SR.PackageSignatureCorruption
What it means
ParseSigningTime parses the <SignatureProperty> section that carries the signing time of a package signature. PackageSignatureCorruption is thrown when a second <SignatureProperty> tag with the expected well-defined Id appears — the OPC signature format allows at most one such signature-time property, so duplicates mean the signature part is corrupt or non-conformant.
Solutions
- Remove the duplicate <SignatureProperty> element with the signing-time Id from the signature part
- Re-sign the package so a single conformant signing-time property is generated
- Validate the signature XML against the OPC digital signature schema before distribution
- Reject the signature as corrupt at validation time if you can't fix the source
Example fix
// before <SignatureProperty Id="SignatureTime" Target="#id1">...</SignatureProperty> <SignatureProperty Id="SignatureTime" Target="#id1">...</SignatureProperty> <!-- duplicate --> // after <SignatureProperty Id="SignatureTime" Target="#id1">...</SignatureProperty>
Defensive patterns
Strategy: try-catch
Validate before calling
bool HasSingleSigningTimeProperty(XElement sigProps) =>
sigProps.Elements().Count(e =>
(string)e.Attribute("Id") == "SignatureTime") <= 1; Try / catch
try { var time = ReadSigningTime(package); }
catch (XmlException ex) when (ex.Message.Contains("corrupt")) { /* treat signature as corrupt; show warning to user */ } Prevention
- Never merge or concatenate signature parts from multiple signing passes
- Schema-validate signatures before distribution
- Regenerate signatures rather than patching them
When it happens
Trigger: Signature validation on a package whose <SignatureProperties> contains more than one <SignatureProperty> element with the expected signing-time Id attribute value.
Common situations: Signature XML duplicated by buggy signing tools or merge artifacts; files concatenated/edited after signing; producers that append extra signature properties with a conflicting Id.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Signature structures are corrupted in this package.
- Signature structures are corrupted in this package.
- SR.PackageSignatureCorruption
- SR.PackageSignatureCorruption
- SR.PartReferenceUriMalformed
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/63d63c745e68068c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs:165
DateTime signingTime = DateTime.Now;
timeFormat = null;
while (reader.Read())
{
//Looking for <SignatureProperty> tag
if (reader.MoveToContent() == XmlNodeType.Element
&& (string.Equals(reader.NamespaceURI, w3cSignatureNameSpace, StringComparison.Ordinal))
&& (string.Equals(reader.LocalName, signaturePropertyTag, StringComparison.Ordinal))
&& reader.Depth == 2)
{
//Verify Attributes
//Look for well-defined Id attribute and if it is present
if (VerifyIdAttribute(reader))
{
//If we encounter more than one <SignatureProperty> tag with the expected
//id, then its an error.
if (signatureTimeIdFound)
throw new XmlException(SR.PackageSignatureCorruption);
else
signatureTimeIdFound = true;
//VerifyTargetAttribute will return false, if the Target attribute is missing
//or contains an incorrect value.
if(VerifyTargetAttribute(reader, signatureId))
{
signingTime = ParseSignatureTimeTag(reader, out timeFormat);
signatureTimePropertyFound = true;
}
}
}
else
//Expected <SignatureProperty> tag not found.
//Look for end tag corresponding to </SignatureProperty> or
//if these are other custom defined properties, then anything with
//depth greater than 2 should be ignored as these can be nested elements.
if (((string.Equals(signaturePropertyTag, reader.LocalName, StringComparison.Ordinal)View on GitHub (pinned to 81131a70a4)