From dbb484b1fe173700fda212406247f63f29917b4a Mon Sep 17 00:00:00 2001 From: Adolfo Huitron Date: Sat, 6 Apr 2024 21:16:49 -0700 Subject: [PATCH] fix: dispose cached certificates when relevant flag is set --- Eavesdrop/Certificates/CertificateProvider.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Eavesdrop/Certificates/CertificateProvider.cs b/Eavesdrop/Certificates/CertificateProvider.cs index 31e0fb2..6ba039e 100644 --- a/Eavesdrop/Certificates/CertificateProvider.cs +++ b/Eavesdrop/Certificates/CertificateProvider.cs @@ -141,9 +141,12 @@ private void Dispose(bool disposing) } TrustedRootCA?.Dispose(); - foreach (X509Certificate2 cachedCertificate in _issuedCertificates.Values) + if (IsDisposingCachedCertificates) { - cachedCertificate.Dispose(); + foreach (X509Certificate2 cachedCertificate in _issuedCertificates.Values) + { + cachedCertificate.Dispose(); + } } _issuedCertificates.Clear(); }