CertificateStoreUnregisterSystemStore Method |
Unregisters an existing system certificate store.
Namespace: MailBee.SecurityAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax public static void UnregisterSystemStore(
string name,
RegistryStoreLocation registryLocation
)
Public Shared Sub UnregisterSystemStore (
name As String,
registryLocation As RegistryStoreLocation
)
Parameters
- name
- Type: SystemString
The name of the existing system store. - registryLocation
- Type: MailBee.SecurityRegistryStoreLocation
The store location in the registry.
Exceptions Remarks 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. |
Note |
---|
This method is not available in .NET Standard 2.0 edition and newer (because it relies on Win32 API). |
Examples This sample registers a store, fills it with some certificates (copied from another store), and unregisters it.
using MailBee.Security;
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);
Imports MailBee.Security
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)
See Also