{"record":{"id":"9a90d6d5b3a62219","repo":"dotnet/wpf","slug":"sr-multiplesignatureorigins","errorCode":null,"errorMessage":"SR.MultipleSignatureOrigins","messagePattern":"SR\\.MultipleSignatureOrigins","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/PackageDigitalSignatureManager.cs","lineNumber":1291,"sourceCode":"                        // don't resolve if external\n                        if (r.TargetMode != TargetMode.Internal)\n                            throw new FileFormatException(SR.PackageSignatureCorruption);\n\n                        // resolve target (may be relative)\n                        Uri targetUri = PackUriHelper.ResolvePartUri(r.SourceUri, r.TargetUri);\n\n                        // if part does not exist - we throw\n                        if (!_container.PartExists(targetUri))\n                            throw new FileFormatException(SR.SignatureOriginNotFound);\n\n                        PackagePart p = _container.GetPart(targetUri);\n\n                        // inspect content type - ignore things we don't understand\n                        if (p.ValidatedContentType().AreTypeAndSubTypeEqual(_originPartContentType))\n                        {\n                            // throw if more than one relationship to an origin part that we recognize\n                            if (_originPartExists)\n                                throw new FileFormatException(SR.MultipleSignatureOrigins);\n\n                            // overwrite default if some container is using some other name\n                            _originPartName = targetUri;\n                            _originPart = p;\n                            _originPartExists = true;\n                        }\n                    }\n                }\n                finally\n                {\n                    _originSearchConducted = true;\n                }\n            }\n            return _originPartExists;\n        }\n\n        //------------------------------------------------------\n        //","sourceCodeStart":1273,"sourceCodeEnd":1309,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/PackageDigitalSignatureManager.cs#L1273-L1309","documentation":"The manager permits exactly one recognizable Digital Signature Origin part per package. During construction, when a second relationship resolves to a part whose content type matches the signature origin content type and an origin was already found, it throws FileFormatException(SR.MultipleSignatureOrigins). Multiple origins make the signature set ambiguous, so the package is rejected.","triggerScenarios":"Constructing PackageDigitalSignatureManager on a package that has two or more root relationships of the signature-origin type resolving to parts with the origin content type (application/vnd.openxmlformats-package.digital-signature-origin).","commonSituations":"Merging two signed packages; a signing tool appended a second origin instead of reusing the existing one; manual .rels editing duplicating the origin relationship.","solutions":["Delete one of the signature origin parts and its relationship from the root .rels, keeping a single origin","Re-sign the package after RemoveAllSignatures so exactly one origin is created","Rebuild the package from the pre-merge state and re-apply signatures","Reject the package at intake with a validation step that counts origin relationships"],"exampleFix":"// before: two origin relationships in _rels/.rels\n// after: keep one\n// <Relationship Type=\".../digital-signature/origin\" Target=\"metadata/sig-origin.xml\" TargetMode=\"Internal\"/>\nusing var pkg = Package.Open(path, FileMode.Open, FileAccess.ReadWrite);\nvar signer = new PackageDigitalSignatureManager(pkg);\nsigner.RemoveAllSignatures();\nsigner.Sign(new Uri(\"/metadata/sig-origin.xml\", UriKind.Relative));","handlingStrategy":"validation","validationCode":"int originCount = pkg.GetRelationshipsByType(\n    \"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin\")\n    .Count(r => r.TargetMode == TargetMode.Internal &&\n                pkg.PartExists(PackUriHelper.ResolvePartUri(\"/\", r.TargetUri)));\nbool ambiguous = originCount > 1;","typeGuard":null,"tryCatchPattern":"try { var signer = new PackageDigitalSignatureManager(pkg); }\ncatch (FileFormatException)\n{ /* reject merged/multi-origin package */ }","preventionTips":["Never merge signed packages without consolidating origins","Reuse the existing origin part when appending signatures","Count origin relationships during package intake validation"],"tags":["opc","signature-origin","ambiguous-metadata","corrupt-package"],"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"}