-
Couldn't load subscription status.
- Fork 5.2k
Add Dispose for X509Chain instance #110740
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
Changes from 2 commits
09af542
1655745
785577f
9fd6c3c
3ea8658
469b268
aa984d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -706,15 +706,31 @@ | |
|
|
||
| if (!verifySignatureOnly) | ||
| { | ||
| X509Chain chain = new X509Chain(); | ||
| chain.ChainPolicy.ExtraStore.AddRange(extraStore); | ||
| chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; | ||
| chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot; | ||
| X509Chain chain = null; | ||
|
Check failure on line 709 in src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignerInfo.cs
|
||
|
|
||
| if (!chain.Build(certificate)) | ||
| try | ||
| { | ||
| X509ChainStatus status = chain.ChainStatus.FirstOrDefault(); | ||
| throw new CryptographicException(SR.Cryptography_Cms_TrustFailure, status.StatusInformation); | ||
| chain = new X509Chain(); | ||
| chain.ChainPolicy.ExtraStore.AddRange(extraStore); | ||
| chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; | ||
| chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot; | ||
|
|
||
| if (!chain.Build(certificate)) | ||
| { | ||
| X509ChainStatus status = chain.ChainStatus.FirstOrDefault(); | ||
| throw new CryptographicException(SR.Cryptography_Cms_TrustFailure, status.StatusInformation); | ||
| } | ||
| } | ||
| finally | ||
|
Check failure on line 724 in src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignerInfo.cs
|
||
| { | ||
| if (chain != null) | ||
|
Check failure on line 726 in src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignerInfo.cs
|
||
| { | ||
| for (int i = 0; i < chain.ChainElements.Count; i++) | ||
| { | ||
| chain.ChainElements[i].Certificate.Dispose(); | ||
| } | ||
| chain.Dispose(); | ||
| } | ||
| } | ||
|
|
||
| // .NET Framework checks for either of these | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
X509Chainctor doesn't do any work, so it can't throw. You can either declare this as nullable or just merge thenew X509Chain()onto this line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed