MailBee.NET Objects 4.0

CertificateCollection Class

Provides methods and properties for accessing collections of Certificate objects.

For a list of all members of this type, see CertificateCollection Members.

System.Object
   System.Collections.CollectionBase
      MailBee.Security.CertificateCollection

public class CertificateCollection : CollectionBase

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

CertificateCollection class represents a group of Certificate objects in MailBee.

On other hand, CertificateStore class represents a group of certificates which exists on operating system level (for instance, certain certificate stores can be used by S/MIME functions to validate certificates) and has certain physical location: file store, system (Windows registry) store, memory store, etc. A certificate store, being an operating system level object, can be persistent and available to other applications while CertificateCollection is only used by those functions of MailBee which can accept or return values containing multiple Certificate objects.

The contents of a certificate store can be represented as CertificateCollection though. You can use CertificateStore.FindCertificates or CertificateStore.GetAllCertificates methods for this.

Example

This sample opens "CA" system certificate store, finds all the certificates issued by Microsoft, creates a new certificate store, adds all the found certificates to this store and saves the store to disk as a file. The sample demonstrates using both CertificateCollection and CertificateStore classes.

[C#]
// To use the code below, import MailBee namespace at the top of your code
using MailBee.Security;

CertificateStore store = new CertificateStore(CertificateStore.IntermediateCA, CertStoreType.System, null);
CertificateCollection coll = store.FindCertificates("Microsoft", CertificateFields.Issuer);
store = new CertificateStore(null, CertStoreType.Memory, null);
store.AddCertificates(coll, true);
store.SaveToFile(@"C:\Temp\microsoft_certificates.sst", CertStoreFileType.Sst, null);
[Visual Basic]
' To use the code below, import MailBee namespace at the top of your code
Imports MailBee.Security

Dim store As CertificateStore = New CertificateStore("CA", CertStoreType.System, Nothing)
Dim coll As CertificateCollection = store.FindCertificates("microsoft", CertificateFields.Issuer)
store = New CertificateStore(Nothing, CertStoreType.Memory, Nothing)
store.AddCertificates(coll, True)
store.SaveToFile("C:\Temp\microsoft_certificates.sst", CertStoreFileType.Sst, Nothing)

Requirements

Namespace: MailBee.Security

Assembly: MailBee.NET (in MailBee.NET.dll)

See Also

CertificateCollection Members | MailBee.Security Namespace | CertificateStore | Certificate