public bool DestroySignedCertificates() { var myCertificates = new X509Certificate2Collection(); var rootCertificates = new X509Certificate2Collection(); try { lock (MyStore) { MyStore.Open(OpenFlags.ReadWrite); var myStoreCertificates = MyStore.Certificates .Find(X509FindType.FindByIssuerName, Issuer, false); myCertificates.AddRange(myStoreCertificates); } lock (RootStore) { RootStore.Open(OpenFlags.ReadWrite); var myRootCertificates = RootStore.Certificates .Find(X509FindType.FindByIssuerName, Issuer, false); rootCertificates.AddRange(myRootCertificates); } return(DestroySignedCertificates(myCertificates, rootCertificates)); } finally { MyStore.Close(); RootStore.Close(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { MyStore.Close(); RootStore.Close(); } }
public void Dispose() { if (MyStore != null) { MyStore.Close(); } if (RootStore != null) { RootStore.Close(); } }
public Agent(HttpClient client, RootStore storage, NavigationManager navigationManager, IJSRuntime js, IToastService toastService) { _client = client; _storage = storage; _navigationManager = navigationManager; _js = js; _toastService = toastService; }
protected virtual bool DestroySignedCertificates( X509Certificate2Collection myCertificates, X509Certificate2Collection rootCertificates) { try { var certificateNames = new List <string>(); if (MyStore != null) { MyStore.RemoveRange(myCertificates); IEnumerable <string> myCertNames = myCertificates.Cast <X509Certificate2>() .Select(c => c.GetNameInfo(X509NameType.SimpleName, false)); certificateNames.AddRange(myCertNames); } if (RootStore != null) { RootStore.RemoveRange(rootCertificates); IEnumerable <string> rootCertNames = rootCertificates.Cast <X509Certificate2>() .Select(c => c.GetNameInfo(X509NameType.SimpleName, false)); certificateNames.AddRange(rootCertNames); } foreach (string certificateName in certificateNames) { if (_certificateCache.ContainsKey(certificateName)) { _certificateCache.Remove(certificateName); } } return(true); } catch (CryptographicException) { return(false); } }