Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5.6k
Fixing SignedXml.CheckSignature for enveloped signature with #xpointer(/) Reference#95404
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d1cdd43
adding failing test case for https://github.com/dotnet/runtime/issues…
m0sa e5d4e3b
adding both positive and negative tests, in-line with recommendations…
m0sa 9e8c558
fix implemented
m0sa b1f74ec
Merge branch 'dotnet:main' into main
m0sa d7542ca
Update src/libraries/System.Security.Cryptography.Xml/src/System/Secu…
m0sa 5f469bb
Update src/libraries/System.Security.Cryptography.Xml/src/System/Secu…
m0sa 2e209c3
Merge branch 'dotnet:main' into main
m0sa 1e0dfdb
Merge branch 'dotnet:main' into main
m0sa 8466fc0
Merge branch 'dotnet:main' into main
m0sa ea74198
using MemberData for tests
m0sa f4c2b27
making memberdata target public
m0sa 50e05b9
Merge branch 'dotnet:main' into main
m0sa 000881c
Merge branch 'dotnet:main' into main
m0sa 90f2ff2
adding test cases for empty <Reference>
m0sa 4fa87c8
Merge branch 'dotnet:main' into main
m0sa 5a58263
Merge branch 'main' into main
m0sa b03f49f
Merge branch 'main' into main
m0sa 6c40861
Merge branch 'main' into main
vcsjones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
25 changes: 19 additions & 6 deletions
25 ...raries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Reference.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -266,18 +266,31 @@ public void LoadXml(XmlElement value) | ||
| // let the transform read the children of the transformElement for data | ||
| transform.LoadInnerXml(transformElement.ChildNodes); | ||
| // Hack! this is done to get around the lack of here() function support in XPath | ||
| if (transform is XmlDsigEnvelopedSignatureTransform | ||
| && _uri != null && (_uri.Length == 0 || _uri[0] == '#')) | ||
| if (transform is XmlDsigEnvelopedSignatureTransform) | ||
| { | ||
| // Walk back to the Signature tag. Find the nearest signature ancestor | ||
| // Signature-->SignedInfo-->Reference-->Transforms-->Transform | ||
| XmlNode? signatureTag = transformElement.SelectSingleNode("ancestor::ds:Signature[1]", nsm); | ||
| // Resolve the reference to get starting point for position calculation. | ||
| XmlNode? referenceTarget = | ||
| _uri.Length == 0 | ||
| ? transformElement.OwnerDocument | ||
| : SignedXml!.GetIdElement(transformElement.OwnerDocument, Utils.GetIdFromLocalUri(_uri, out bool _)); | ||
| // This needs to match the way CalculateSignature resolves URI references. | ||
| XmlNode? referenceTarget = null; | ||
| if (_uri == null || _uri.Length == 0) | ||
| { | ||
| referenceTarget = transformElement.OwnerDocument; | ||
| } | ||
| else if (_uri[0] == '#') | ||
| { | ||
| string idref = Utils.ExtractIdFromLocalUri(_uri); | ||
| if (idref == "xpointer(/)") | ||
vcsjones marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| { | ||
| referenceTarget = transformElement.OwnerDocument; | ||
| } | ||
| else | ||
| { | ||
| referenceTarget = SignedXml!.GetIdElement(transformElement.OwnerDocument, idref); | ||
vcsjones marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| } | ||
| XmlNodeList? signatureList = referenceTarget?.SelectNodes(".//ds:Signature", nsm); | ||
| if (signatureList != null) | ||
41 changes: 41 additions & 0 deletions
41 src/libraries/System.Security.Cryptography.Xml/tests/SignedXmlTest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.