Skip to content

Commit 85a54f2

Browse files
authored
Add dispose of X509Chain in SignedXml (#115909)
* Add dispose of X509Chain in SignedXml * Change try finally to using * Remove spaces * Add braces for using block
1 parent a01d6d6 commit 85a54f2

File tree

1 file changed

+7
-4
lines changed
  • src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml

1 file changed

+7
-4
lines changed

src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,13 @@ public bool CheckSignature(X509Certificate2 certificate, bool verifySignatureOnl
353353
}
354354

355355
// Do the chain verification to make sure the certificate is valid.
356-
X509Chain chain = new X509Chain();
357-
chain.ChainPolicy.ExtraStore.AddRange(BuildBagOfCerts());
358-
bool chainVerified = chain.Build(certificate);
359-
SignedXmlDebugLog.LogVerifyX509Chain(this, chain, certificate);
356+
bool chainVerified = false;
357+
using (X509Chain chain = new X509Chain())
358+
{
359+
chain.ChainPolicy.ExtraStore.AddRange(BuildBagOfCerts());
360+
chainVerified = chain.Build(certificate);
361+
SignedXmlDebugLog.LogVerifyX509Chain(this, chain, certificate);
362+
}
360363

361364
if (!chainVerified)
362365
{

0 commit comments

Comments
 (0)