Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ private void Verify(

if (!verifySignatureOnly)
{
X509Chain chain = new X509Chain();
using X509Chain chain = new X509Chain();
Copy link
Member

Choose a reason for hiding this comment

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

Instead of the implicit scope using, this should be a normal block-body using statement, and the end of the block should be at the end of the if that calls chain.Build() (so between that block and the EKU check)

chain.ChainPolicy.ExtraStore.AddRange(extraStore);
chain.ChainPolicy.RevocationMode = X509RevocationMode.Online;
chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
Copy link
Member

Choose a reason for hiding this comment

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

If we're trying to reduce finalizations, then line 714 probably wants to change to

bool trustedChain = chain.Build(certificate);

for (int i = 0; i < chain.ChainElements.Length; i++)
{
    chain.ChainElements[i].Certificate.Dispose();
}

if (!trustedChain)

Or instead of a using here make it a try/finally and put that cleanup in the finally.

The certificate instances in ChainElements are all new instances (copies) of the input objects, which can be seen via the NotSame assertions in

Assert.NotSame(cert, chain.ChainElements[0].Certificate);
(and the rest of the file); so there's no impact from extraStore or what have you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added try/finally

Expand Down