Certificate Class |
Namespace: MailBee.Security
The Certificate type exposes the following members.
Name | Description | |
---|---|---|
Certificate(X509Certificate2) |
Initializes certificate from X509Certificate2 object.
| |
Certificate(Byte, CertFileType, String) |
Loads the certificate from binary data and returns it as Certificate object.
| |
Certificate(String, CertFileType, String) |
Loads the certificate from a file and returns it as Certificate object.
|
Name | Description | |
---|---|---|
Dispose |
Releases the resources associated with the Certificate 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.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
LoadFromFileAsync |
async/await version of Certificate(String, CertFileType, String).
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
SaveToFile |
Saves the certificate into a file on disk.
| |
SaveToFileAsync |
async/await version of SaveToFile(String, CertFileType, String).
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Validate |
Checks if the certificate is valid.
| |
Validate(X509Certificate2Collection) |
Checks if the certificate is valid.
| |
Validate(CertificateStore) |
Checks if the certificate is valid.
|
Name | Description | |
---|---|---|
AsX509Certificate |
Gets the certificate as X509Certificate2 object.
| |
EmailAddress |
Gets the e-mail address of the certificate principal.
| |
HasPrivateKey |
Gets whether the certificate has a private key.
| |
IssuedBy |
Gets the name of the certification authority that issued the X.509 certificate.
| |
IssuedTo |
Gets the name of the entity this certificate was issued to.
| |
IssuerDetails |
Gets the name of the certification authority which issued this X.509 certificate.
| |
KeyAlgorithmString |
Gets a string containing OID of algorithm used to generate a public key of X.509 certificate.
| |
LastResult |
Gets a numeric code of the last error.
| |
Name |
Gets the details about the principal to which the certificate was issued.
| |
PublicKey |
Gets a public key for X.509 certificate as a byte array.
| |
PublicKeyString |
Gets a string containing a public key for X.509 certificate.
| |
RawData |
Gets the raw X.509 certificate data as a byte array.
| |
SerialNumber |
Gets the serial number of the X.509-formatted certificate as a byte array.
| |
SerialNumberString |
Gets the serial number of the X.509-formatted certificate as a string.
| |
SignatureAlgorithm |
Gets the information about cryptographic algorithm used to sign the certificate.
| |
Subject |
Gets the subject of X.509 certificate.
| |
SubjectAlternativeName |
Gets the subject's alternative name of X.509 certificate.
| |
ThrowExceptions |
Gets or sets whether the object will throw exceptions on errors.
| |
Thumbprint |
Gets the thumbprint of a certificate.
| |
ValidFromDate |
Gets the date the certificate is valid from.
| |
ValidToDate |
Gets the date the certificate certificate is no longer valid from.
|
Certificate class represents a digital certificate in MailBee.
Digital certificate is a statement which uses a digital signature to bind together a public key of an entity with information about this entity. After the trusted organization (also called a certification authority, CA) has verified the entity, it issues the requested certificate to the entity.
Certificates can contain different types of data, such as the serial number of the certificate, the algorithm used to sign the certificate, the name of the CA that issued the certificate, the name and public key of the entity requesting the certificate, and the CA's signature.
EmailAddress and HasPrivateKey are the most important properties of the certificate.
Note |
---|
To use this class, make sure MailBee.NET Security is licensed (MailBee.NET Objects full bundle does include the license). |
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; // The actual code (put it into a method of your class). Certificate cert = new Certificate(@"C:\Temp\certificate.cer", CertFileType.Cer, null); Console.WriteLine("Email address: " + cert.EmailAddress); Console.WriteLine("Private key available: " + cert.HasPrivateKey); Console.WriteLine("Issued by: " + cert.IssuedBy); Console.WriteLine("Issued to: " + cert.IssuedTo); Console.WriteLine("Issuer: " + cert.IssuedBy); Console.WriteLine("Key algorithm: " + cert.KeyAlgorithmString); Console.WriteLine("Name: " + cert.Name); Console.WriteLine("Public key: " + cert.PublicKeyString); Console.WriteLine("Serial number: " + cert.SerialNumberString); Console.WriteLine("Subject: " + cert.Subject); Console.WriteLine("Valid from " + cert.ValidFromDate + " till " + cert.ValidToDate);