Skip to content

Add dispose of X509Chain in SignedXml #115909

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

Conversation

MaxPatri
Copy link
Contributor

Call Dispose for X509Chain class instance
I didn't add chain.ChainElements[*].Certificate.Dispose() as mentioned here
because I'm not sure that we should dispose all chained certificates. One of them is passed through the method parameters

Found by Linux Verification Center (linuxtesting.org) with SVACE.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label May 22, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

}
finally
{
chain.Dispose();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only the variable is disposed and nothing else, then using should be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @bartonjs?

@vcsjones
Copy link
Member

LGTM. @bartonjs?

Is OOF until next week, but predicting what Jeremy will say: "Please use a using with braces, not a using declaration". S.Security only uses using declarations in unit tests.

@MaxPatri MaxPatri force-pushed the Add-X509Chain-dispose-call-in-SignedXml branch from 85c875e to de78f2c Compare May 29, 2025 06:49
@stephentoub stephentoub merged commit 85a54f2 into dotnet:main Jun 1, 2025
83 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Security community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants