Skip to content

Add dispose of X509Chain in SignedXml#115909

Merged
stephentoub merged 4 commits into
dotnet:mainfrom
MaxPatri:Add-X509Chain-dispose-call-in-SignedXml
Jun 1, 2025
Merged

Add dispose of X509Chain in SignedXml#115909
stephentoub merged 4 commits into
dotnet:mainfrom
MaxPatri:Add-X509Chain-dispose-call-in-SignedXml

Conversation

@MaxPatri

Copy link
Copy Markdown
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
@dotnet-policy-service

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@stephentoub stephentoub left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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