I am able to load certificates that are available on my windows machines in a ListView using C# and by selecting a certificate, I added a functionality to delete a selected certificate using the code below:
CertificateUtility util = new CertificateUtility();
util.StoreName = Convert.ToString(this.drpdwnStores.SelectedValue);
X509Store x509Store = new X509Store(util.StoreName, StoreLocation.LocalMachine);
x509Store.Open(OpenFlags.OpenExistingOnly);
X509Certificate2Collection certColl = x509Store.Certificates.Find(
X509FindType.FindBySerialNumber, "mycert", true);
X509Certificate2 deletethis = certColl[0];
if (deletethis != null) {
x509Store.Remove(deletethis);
}
This line x509Store.Remove(deletethis);
give me Access denied.
I am an admin on this particular machine
Does anyone know how to fix this?