Using the -ss
option of Microsoft tool MakeCert.exe
(-ss specifies the subject's certificate store name that stores the output certificate), I create my own store on a server. I'am able to remove my certificate programaticaly, but I'am not able to remove the store itself. According to the error message this not seems to be supported by the provider.
I can't even use the MMC snapin (certmgr.msc) to remove it. Does anybody know how to do that ?
PS cert:\LocalMachine> Remove-Item .\SigningStore
Remove-Item : L'exécution du fournisseur s'est arrêtée, car le fournisseur ne prend pas en charge cette opération.
Au niveau de ligne : 1 Caractère : 12
+ Remove-Item <<<< .\SigningStore
+ CategoryInfo : NotImplemented: (:) [Remove-Item], PSNotSupportedException
+ FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.RemoveItemCommand
The only way I found was to use CertUnregisterSystemStore Win32 API
I accidentally created a store called Personal and wanted to get rid of it (of course). Two personal stores to look for ughhh. Anyways, I added a certificate that I had created to that store, copied the thumbprint (and removed the spaces) and then searched the registry for the thumbprint. I discovered I could make them go away by deleting the key (in my case Personal) at [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\Personal] (if in the local machine) or at [HKEY_CURRENT_USER\Software\Microsoft\SystemCertificates\Personal] is in current user. I knew that it wasn't the other one called Personal because the real personal store is actually stored as My.
EDIT: I had to remove a few other keys to solve this but basically search carefully and examine each entry that matches what you are trying to get rid of. For each match, export to a reg file and then delete and test.
This post was a bit helpful as well: http://banachowski.com/deprogramming/2011/01/deleting-unwanted-certificate-stores-from-windows/
Read this and add-type with c# code with pinvoke (already done!) of crypt32.dll
Use a PowerShell cmdlet:
Remove-Item -Path cert:\LocalMachine\StoreYouWantToDelete
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With