예제 #1
0
        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();
            }
        }
예제 #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         MyStore.Close();
         RootStore.Close();
     }
 }
예제 #3
0
        public void Dispose()
        {
            if (MyStore != null)
            {
                MyStore.Close();
            }

            if (RootStore != null)
            {
                RootStore.Close();
            }
        }
예제 #4
0
 public Agent(HttpClient client,
              RootStore storage,
              NavigationManager navigationManager,
              IJSRuntime js,
              IToastService toastService)
 {
     _client            = client;
     _storage           = storage;
     _navigationManager = navigationManager;
     _js           = js;
     _toastService = toastService;
 }
예제 #5
0
        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); }
        }