Provides access to the client and server SSL certificate settings.
A reference to the client and server SSL certificate settings.
The following code should be used to access the server certificate (assuming server is an SmtpServer class instance currently used by Smtp component as an SMTP server definition): server.SslCertificates.Server. To set the client certificate, the developer should assign server.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).
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.SmtpMail; using MailBee.Security; class Sample { static void Main(string[] args) { Smtp mailer = new Smtp(); SmtpServer server = new SmtpServer("mail.domain.com"); server.SslMode = SslStartupMode.UseStartTls; server.SslCertificates.Client = new Certificate(@"C:\my.pfx", CertFileType.Pfx, "secret"); mailer.SmtpServers.Add(server); mailer.Connect(); mailer.Hello(); Console.WriteLine("The server certificate info"); Console.WriteLine("==========================="); Console.WriteLine("Issued by: " + server.SslCertificates.Server.IssuedBy); Console.WriteLine("Issued to: " + server.SslCertificates.Server.IssuedTo); Console.WriteLine("Valid from: " + server.SslCertificates.Server.ValidFromDate); Console.WriteLine("Valid to: " + server.SslCertificates.Server.ValidToDate); mailer.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.SmtpMail Imports MailBee.Security Class Sample Shared Sub Main(ByVal args() As String) Dim mailer As Smtp = New Smtp Dim server As SmtpServer = New SmtpServer("mail.domain.com") server.SslMode = SslStartupMode.UseStartTls server.SslCertificates.Client = New Certificate("C:\my.pfx", CertFileType.Pfx, "secret") mailer.SmtpServers.Add(server) mailer.Connect() mailer.Hello() Console.WriteLine("The server certificate info") Console.WriteLine("===========================") Console.WriteLine("Issued by: " & server.SslCertificates.Server.IssuedBy) Console.WriteLine("Issued to: " & server.SslCertificates.Server.IssuedTo) Console.WriteLine("Valid from: " & server.SslCertificates.Server.ValidFromDate) Console.WriteLine("Valid to: " & server.SslCertificates.Server.ValidToDate) mailer.Disconnect() End Sub End Class
SmtpServer Class | MailBee.SmtpMail Namespace | Certificate | CertificateStore