CertificateStore Class |
Namespace: MailBee.Security
The CertificateStore type exposes the following members.
Name | Description | |
---|---|---|
CertificateStore |
Creates a new certificate store in memory.
| |
CertificateStore(X509Store) | Initializes CertificateStore instance from the existing X509Store object. | |
CertificateStore(Byte, String) |
Opens an existing store of certificates from a memory footprint of a PFX (.P12, PKCS #12) file.
| |
CertificateStore(Byte, CertStoreType, CryptoServiceProvider) |
Opens an existing store of certificates from a memory footprint of a PKCS #7 (.P7B) or Serialized Certificate Storage (.SST) file.
| |
CertificateStore(String, CertStoreType, String) |
Opens an existing or creates a new store of certificates.
| |
CertificateStore(String, CertStoreType, String, CryptoServiceProvider, RegistryStoreLocation) |
Opens an existing or creates a new store of certificates.
|
Name | Description | |
---|---|---|
AddCertificate |
Adds the specified certificate to the store.
| |
AddCertificates |
Adds all the certificates from the specified collection to the store.
| |
DeleteCertificate |
Removes the specified certificate from the store.
| |
Dispose |
Releases the resources associated with the current CertificateStore object.
| |
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.) | |
FindCertificates |
Searches the certificates in the store by the specified criteria.
| |
GetAllCertificates |
Creates and returns a collection of all the certificates contained in the certificate store.
| |
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.) | |
RegisterSystemStore |
Registers a new system certificate store.
| |
SaveToFile |
Saves the certificate store into a file.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
UnregisterSystemStore |
Unregisters an existing system certificate store.
|
Name | Description | |
---|---|---|
IntermediateCA |
Gets the name of the system certificate store containing certificates of intermediate certification authorities.
| |
OtherPeople |
Gets the name of the system certificate store containing certificates of other entities such as your address book members.
| |
Personal |
Gets the name of the system certificate store containing personal certificates.
| |
RootCA |
Gets the name of the system certificate store containing certificates of trusted root certification authorities.
|
Name | Description | |
---|---|---|
LastResult |
Gets a numeric code of the last error.
| |
ThrowExceptions |
Gets or sets whether the object will throw exceptions on errors.
|
Certificate store is a persistent or memory storage of certificates. There are 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(String, RegistryStoreLocation) method.
Note |
---|
In UWP, this class is available starting from Windows 10 Fall Creators update. |
Note |
---|
In .NET Standard 2.0 edition, this class is a thin wrapper around X509Store. Moreover, Smime class now provides new crypto methods with "2" suffix in their names which make using CertificateStore class unnecessary. |
Note |
---|
ASP.NET application developers should be aware that the system certificate stores of ASP.NET user may contain fewer 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. |
// 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("------------------------------"); }