CertificateCollectionRemove Method (Certificate) |
Namespace: MailBee.SecurityAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool Remove(
Certificate cert
)
Public Function Remove (
cert As Certificate
) As Boolean
Parameters
- cert
- Type: MailBee.SecurityCertificate
The certificate that should be removed from the collection.
Return Value
Type:
Booleantrue if the certificate was removed from the collection;
false if the certificate is not contained in the collection.
Exceptions Examples The sample removes all the certificates without private key from the collection.
using MailBee.Security;
CertificateStore store = new CertificateStore(@"C:\Temp\certificate.pfx", CertStoreType.PfxFile, "password");
CertificateCollection col = store.GetAllCertificates();
for (int i = col.Count - 1; i >= 0 ; i--)
{
if (!col[i].HasPrivateKey)
{
col.Remove(col[i]);
}
}
if (col.Count > 0)
{
CertificateStore newStore = new CertificateStore();
newStore.AddCertificates(col, true);
newStore.SaveToFile(@"C:\Temp\private.sst", CertStoreFileType.Sst, null);
}
Imports MailBee.Security
Dim store As CertificateStore = New CertificateStore("C:\Temp\certificate.pfx", CertStoreType.PfxFile, "password")
Dim col As CertificateCollection = store.GetAllCertificates()
For i As Integer = col.Count - 1 To 0 Step -1
If Not col(i).HasPrivateKey Then
col.Remove(col(i))
End If
Next
If col.Count > 0 Then
Dim newStore As CertificateStore = New CertificateStore
newStore.AddCertificates(col, True)
newStore.SaveToFile("C:\Temp\private.sst", CertStoreFileType.Sst, Nothing)
End If
See Also