Unregisters an existing system certificate store.
Unregistering the store physically removes the store along with all the certificates.
Note It's not recommended to unregister system stores unless they had been created by your applications. Unregistering a store which is used by the operating system may cause unpredictable results.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | name is a null reference (Nothing in Visual Basic). |
| MailBeeCertificateStoreWin32Exception | Win32 returned an error on attempt to register a store. |
This sample registers a store, fills it with some certificates (copied from another store), and unregisters it.
[C#] // To use the code below, import MailBee namespace at the top of your code using MailBee.Security; // The actual code (put it into a method of your class). CertificateStore.RegisterSystemStore("TestStore", RegistryStoreLocation.CurrentUser); CertificateStore newStore = new CertificateStore("TestStore", CertStoreType.System, null); CertificateStore myStore = new CertificateStore(CertificateStore.Personal, CertStoreType.System, null); CertificateCollection coll = myStore.FindCertificates("thawte", CertificateFields.EmailAddress); newStore.AddCertificates(coll, false); coll = newStore.GetAllCertificates(); foreach (Certificate cert in coll) { Console.WriteLine(cert.IssuedTo); Console.WriteLine(cert.IssuedBy); Console.WriteLine(cert.EmailAddress); Console.WriteLine(cert.ValidToDate); Console.WriteLine("Has private key: " + cert.HasPrivateKey); Console.WriteLine("------------------------------"); } CertificateStore.UnregisterSystemStore("TestStore", RegistryStoreLocation.CurrentUser);
[Visual Basic] ' To use the code below, import MailBee namespace at the top of your code Imports MailBee.Security ' The actual code (put it into a method of your class). CertificateStore.RegisterSystemStore("TestStore", RegistryStoreLocation.CurrentUser) Dim newStore As CertificateStore = New CertificateStore("TestStore", CertStoreType.System, Nothing) Dim myStore As CertificateStore = New CertificateStore(CertificateStore.Personal, CertStoreType.System, Nothing) Dim coll As CertificateCollection = myStore.FindCertificates("thawte", CertificateFields.EmailAddress) newStore.AddCertificates(coll, False) coll = newStore.GetAllCertificates() For Each cert As Certificate In coll Console.WriteLine(cert.IssuedTo) Console.WriteLine(cert.IssuedBy) Console.WriteLine(cert.EmailAddress) Console.WriteLine(cert.ValidToDate) Console.WriteLine("Has private key: " & cert.HasPrivateKey) Console.WriteLine("------------------------------") Next CertificateStore.UnregisterSystemStore("TestStore", RegistryStoreLocation.CurrentUser)
CertificateStore Class | MailBee.Security Namespace