By default most systems allow SSL 3.0, TLS 1.0, 1.2 and 1.2 to be used.
TLS 1.2 is the most secure version of SSL/TLS protocols. It is easy to force the connection to use it. All you need to do is to set Ftp.SSLConfiguration.EnabledSslProtocols property to SslProtocols.Tls12:
// C# using (Imap imap = new Imap()) { imap.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12; imap.ConnectSSL("imap.example.com"); imap.UseBestLogin("user","password"); // ... imap.Close(); }
' VB.NET Using imap As New Imap() imap.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12 imap.ConnectSSL("imap.example.com") imap.UseBestLogin("user@example.com", "password") '... imap.Close() End Using
For explicit SSL/TLS, code is almost the same. You first connect to non-secure port and secure the connection using Imap.StartTLS command:
// C# using (Imap imap= new Imap()) { imap.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12; imap.Connect("imap.example.com"); imap.StartTLS(); imap.UseBestLogin("user@example.com","password"); // ... imap.Close(); }
' VB.NET Using imap As New Imap() imap.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12 imap.Connect("imap.example.com") imap.StartTLS() imap.UseBestLogin("user@example.com", "password") '... imap.Close() End Using
To use TLS 1.2 .NET Framework 4.5+ must be installed on your machine and you application should target .NET 4.5+.
It is possible to use TLS 1.2 in applications targeting .NET <4.5, but 4.5 must be installed on the machine. After you have .NET 4.5 installed, your 2.0-4.0 apps will use the 4.5 System.dll and you can enable TLS 1.2 using this code: [csharp] imap.SSLConfiguration.EnabledSslProtocols = (SecurityProtocolType)3072; [/csharp]