CertificateCollection Class |
Namespace: MailBee.Security
The CertificateCollection type exposes the following members.
Name | Description | |
---|---|---|
CertificateCollection | Initializes a new instance of the CertificateCollection class |
Name | Description | |
---|---|---|
Add |
Adds the specified certificate to the collection.
| |
Clear | Removes all objects from the CollectionBase instance. This method cannot be overridden. (Inherited from CollectionBase.) | |
Contains |
Checks whether the specified certificate is contained in the collection or not.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
FromX509Certificate2Collection |
Initializes CertificateCollection from the existing X509Certificate2Collection.
| |
GetEnumerator | Returns an enumerator that iterates through the CollectionBase instance. (Inherited from CollectionBase.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnClear | Performs additional custom processes when clearing the contents of the CollectionBase instance. (Inherited from CollectionBase.) | |
OnClearComplete | Performs additional custom processes after clearing the contents of the CollectionBase instance. (Inherited from CollectionBase.) | |
OnInsert | Performs additional custom processes before inserting a new element into the CollectionBase instance. (Inherited from CollectionBase.) | |
OnInsertComplete | Performs additional custom processes after inserting a new element into the CollectionBase instance. (Inherited from CollectionBase.) | |
OnRemove | Performs additional custom processes when removing an element from the CollectionBase instance. (Inherited from CollectionBase.) | |
OnRemoveComplete | Performs additional custom processes after removing an element from the CollectionBase instance. (Inherited from CollectionBase.) | |
OnSet | Performs additional custom processes before setting a value in the CollectionBase instance. (Inherited from CollectionBase.) | |
OnSetComplete | Performs additional custom processes after setting a value in the CollectionBase instance. (Inherited from CollectionBase.) | |
OnValidate | Performs additional custom processes when validating a value. (Inherited from CollectionBase.) | |
Remove(String) |
Removes the certificate with the specified name of the entity this certificate was issued to.
| |
Remove(Certificate) |
Removes the specified Certificate from the collection.
| |
RemoveAt | Removes the element at the specified index of the CollectionBase instance. This method is not overridable. (Inherited from CollectionBase.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
ToX509Certificate2Collection |
Initializes X509Certificate2Collection from the current CertificateCollection.
|
Name | Description | |
---|---|---|
Capacity | Gets or sets the number of elements that the CollectionBase can contain. (Inherited from CollectionBase.) | |
Count | Gets the number of elements contained in the CollectionBase instance. This property cannot be overridden. (Inherited from CollectionBase.) | |
InnerList | Gets an ArrayList containing the list of elements in the CollectionBase instance. (Inherited from CollectionBase.) | |
ItemInt32 |
Gets the certificate at the specified zero-based index.
| |
ItemString |
Gets the certificate by the name of the principal to which this certificate was issued.
| |
List | Gets an IList containing the list of elements in the CollectionBase instance. (Inherited from CollectionBase.) |
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.
Note |
---|
Starting from .NET Standard 2.0 edition (e.g. .NET Core 2.0 and newer), it's recommended to use system-provided X509Certificate2 and X509Certificate2Collection classes directly. The only case when you'll need Certificate or CertificateCollection is calling SignAndEncrypt(MailMessage, Certificate, CertificateCollection) method. You can use Certificate(X509Certificate2) and FromX509Certificate2Collection(X509Certificate2Collection) methods to wrap X509Certificate2 and X509Certificate2Collection objects with their MailBee counterparts. |
// 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);