{"id":5121,"date":"2016-11-18T16:43:00","date_gmt":"2016-11-18T14:43:00","guid":{"rendered":"https:\/\/www.limilabs.com\/blog\/?p=5121"},"modified":"2023-08-07T13:50:36","modified_gmt":"2023-08-07T11:50:36","slug":"use-tls12-with-imap","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/use-tls12-with-imap","title":{"rendered":"Using TLS 1.2 with .NET IMAP client"},"content":{"rendered":"\n<p>In this article, you&#8217;ll find an extensive tutorial detailing the process of setting up the <a href=\"\/mail\">Mail.dll IMAP client<\/a> to make use of the TLS 1.2 encryption protocol.<\/p>\n\n\n\n<p>This security enhancement guarantees the protection of incoming email messages through IMAP, shielding them from potential risks and unauthorized entry.<\/p>\n\n\n\n<p>Typically, clients and IMAP servers engage in a negotiation process to determine compatible SSL\/TLS versions. Many systems no longer support SSL 3.0, TLS 1.0, or 1.1. Mail.dll IMAP component automatically uses the latest available TLS version.<\/p>\n\n\n\n<p>TLS 1.2 and 1.3 are the most secure versions of TLS protocols. You can force the connection to use it. <\/p>\n\n\n\n<p>All you need to do is to set <em>Imap.SSLConfiguration.EnabledSslProtocols<\/em> property to <em>SslProtocols.Tls12<\/em> before issuing <code>ConnectSSL<\/code> or <code>Connect<\/code> and <code>StartTLS<\/code> sequence:<\/p>\n\n\n\n<div class=\"well\">Here you can <a href=\"\/blog\/use-ssl-with-imap\">learn more on how TLS\/SSL and StartTLS work in IMAP protocol<\/a><\/div>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/\/ C#\n\nusing (Imap imap = new Imap())\n{\n    imap.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12;\n\n    imap.ConnectSSL(\"imap.example.com\");\n\n    imap.UseBestLogin(\"user\",\"password\");\n\n    \/\/ ... \n\n    imap.Close();\n}\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: vb; title: ; notranslate\" title=\"\">\n' VB.NET\n\nUsing imap As New Imap()\n\timap.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12\n\n\timap.ConnectSSL(\"imap.example.com\")\n\n\timap.UseBestLogin(\"user@example.com\", \"password\")\n\n\t'...\n\n\timap.Close()\nEnd Using\n<\/pre><\/div>\n\n\n<p>For <a href=\"\/blog\/ssl-vs-tls-vs-starttls-stls\">explicit SSL\/TLS<\/a>, code is almost the same. You first connect to a default, non-secure IMAP port and secure the connection using <code>Imap.StartTLS<\/code> method:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/\/ C#\n\nusing (Imap imap= new Imap())\n{\n    imap.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12;\n\n    imap.Connect(\"imap.example.com\");\n    imap.StartTLS();\n\n    imap.UseBestLogin(\"user@example.com\",\"password\");\n\n    \/\/ ... \n\n    imap.Close();\n}\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: vb; title: ; notranslate\" title=\"\">\n' VB.NET\n\nUsing imap As New Imap()\n\timap.SSLConfiguration.EnabledSslProtocols = SslProtocols.Tls12\n\n\timap.Connect(\"imap.example.com\")\n\timap.StartTLS()\n\n\timap.UseBestLogin(\"user@example.com\", \"password\")\n\n\t'...\n\n\timap.Close()\nEnd Using\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Older .NET framework versions<\/h2>\n\n\n\n<p>To use TLS 1.2 in IMAP client at least .NET Framework 4.5+ must be installed on your machine and your application should target .NET 4.5+.<\/p>\n\n\n\n<p>It is possible to use TLS 1.2 in applications targeting earlier .NET framework versions, but 4.5 must be installed on the machine. After you have .NET 4.5 installed, your 2.0 &#8211; 4.0 apps will use the 4.5 System.dll and you can enable TLS 1.2 using this code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/\/ C#\n\nimap.SSLConfiguration.EnabledSslProtocols = \n    (SecurityProtocolType)3072;\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>In this article, you&#8217;ll find an extensive tutorial detailing the process of setting up the Mail.dll IMAP client to make use of the TLS 1.2 encryption protocol. This security enhancement guarantees the protection of incoming email messages through IMAP, shielding them from potential risks and unauthorized entry. Typically, clients and IMAP servers engage in a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[28,53,83,114],"class_list":["post-5121","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-imap","tag-ssl","tag-tls","tag-tls-1-2"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5121"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=5121"}],"version-history":[{"count":15,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5121\/revisions"}],"predecessor-version":[{"id":6526,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5121\/revisions\/6526"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=5121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=5121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=5121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}