MailBee.NET Objects 4.0

Imap.SslCertificates Property

Provides access to the client and server SSL certificate settings.

public MailBee.Security.ClientServerCertificates SslCertificates {get;}

Property Value

A reference to the client and server SSL certificate settings.

Remarks

The following code should be used to access the server certificate (assuming imp is an Imap component instance): imp.SslCertificates.Server. To set the client certificate, the developer should assign imp.SslCertificates.Client property.

Note   Prior to starting using certificates, the developer must set LicenseKey property of Powerup class (this can be accomplished in the code, in the config file such as app.config, or in the registry).

Example

This console sample establishes secure connection with the mail server using the private certificate of the client and then displays various information about the server certificate. The client certificate is taken from a file (MailBee can also read certificates from the registry, see CertificateStore class description for details).

[C#]
using System;
using MailBee;
using MailBee.ImapMail;
using MailBee.Security;

class Sample
{
    static void Main(string[] args)
    {
        Imap imp = new Imap();
        imp.SslMode = SslStartupMode.OnConnect;
        imp.SslCertificates.Client = new Certificate(@"C:\my.pfx", CertFileType.Pfx, "secret");
        imp.Connect("mail.domain.com", 993);
        Console.WriteLine("The server certificate info");
        Console.WriteLine("===========================");
        Console.WriteLine("Issued by:    " + imp.SslCertificates.Server.IssuedBy);
        Console.WriteLine("Issued to:    " + imp.SslCertificates.Server.IssuedTo);
        Console.WriteLine("Valid from:    " + imp.SslCertificates.Server.ValidFromDate);
        Console.WriteLine("Valid to:    " + imp.SslCertificates.Server.ValidToDate);
        imp.Disconnect();
    }
}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.ImapMail
Imports MailBee.Security

Class Sample
    Shared Sub Main(ByVal args() As String)
        Dim imp As Imap = New Imap
        imp.SslMode = SslStartupMode.OnConnect
        imp.SslCertificates.Client = New Certificate("C:\my.pfx", CertFileType.Pfx, "secret")
        imp.Connect("mail.domain.com", 993)
        Console.WriteLine("The server certificate info")
        Console.WriteLine("===========================")
        Console.WriteLine("Issued by:    " & imp.SslCertificates.Server.IssuedBy)
        Console.WriteLine("Issued to:    " & imp.SslCertificates.Server.IssuedTo)
        Console.WriteLine("Valid from:    " & imp.SslCertificates.Server.ValidFromDate)
        Console.WriteLine("Valid to:    " & imp.SslCertificates.Server.ValidToDate)
        imp.Disconnect()
    End Sub
End Class

See Also

Imap Class | MailBee.ImapMail Namespace | Certificate | CertificateStore