I have some code that create a custom store to test some certificate related operation, how can I be sure that the store is empty and is removed from the system? I cannot see it in the Certificate Manager.
Example:
X509Store store = new X509Store("HelloWorld", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
// add and remove some store
// some operations etc.
store.Close();
store.Dispose();
The Close
and Dispose
just clean up the resource allocation in the code, but I don't think it actually deletes it off the drive. I looked around and it doesn't seem like there is a way to "delete the store".
Can I assumed that Windows would automatically remove an empty X509Store? If not, how can I clean it up?
There is no managed way to delete the store. You need to p/invoke CertUnregisterPhysicalStore native function.