MailBee.NET Objects 4.0

CertificateStore Class

Provides the methods and properties for accessing certificate stores.

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

System.Object
   MailBee.Security.CertificateStore

public class CertificateStore : IDisposable

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

Certificate store is a persistent or memory storage of certificates. There is a number of types of certificate stores supported by Windows (and therefore by MailBee), listed in CertStoreType enumeration.

Stores of System type play key role in many security procedures. You can view the contents of the system stores in "Internet Options/Content/Certificates" dialog of Internet Explorer. CertificateStore class defines several constants which refer to the standard system stores (such as Personal). Also, you can create your own system stores with RegisterSystemStore method.

Note   ASP.NET application developers should be aware that the system certificate stores of ASP.NET user may contain less number of certificates in comparison to those of regular users. See S/MIME Demo for ASP.NET sample project shipped with the product for more information on how to deal with this.

Example

This sample opens the standard system store and displays the details for each certificate.

[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 store = new CertificateStore(CertificateStore.Personal, CertStoreType.System, null);
CertificateCollection coll = store.GetAllCertificates();

foreach (Certificate cert in coll)
{
    Console.WriteLine("Issued to: " + cert.IssuedTo);
    Console.WriteLine("Issued by: " + cert.IssuedBy);
    Console.WriteLine("Email: " + cert.EmailAddress);
    Console.WriteLine("Valid to: " + cert.ValidToDate);
    Console.WriteLine("Has private key: " + cert.HasPrivateKey);
    Console.WriteLine("------------------------------");
}
[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).
Dim store As CertificateStore = New CertificateStore(CertificateStore.Personal, CertStoreType.System, Nothing)
Dim coll As CertificateCollection = store.GetAllCertificates()

For Each cert As Certificate In coll
    Console.WriteLine("Issued to: " & cert.IssuedTo)
    Console.WriteLine("Issued by: " & cert.IssuedBy)
    Console.WriteLine("Email: " & cert.EmailAddress)
    Console.WriteLine("Valid to: " & cert.ValidToDate)
    Console.WriteLine("Has private key: " & cert.HasPrivateKey)
    Console.WriteLine("------------------------------")
Next

Requirements

Namespace: MailBee.Security

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

See Also

CertificateStore Members | MailBee.Security Namespace | Certificate | CertificateCollection