{"id":3412,"date":"2012-09-24T15:02:42","date_gmt":"2012-09-24T13:02:42","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=3412"},"modified":"2013-06-26T09:20:23","modified_gmt":"2013-06-26T07:20:23","slug":"send-signed-email-smime-sha-512","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/send-signed-email-smime-sha-512","title":{"rendered":"Send signed email using S\/MIME (SHA\u2011512)"},"content":{"rendered":"<p>In many cases it is required to use better that standard signing algorithms. With Mail.dll it is easy to specify algorithm that is used for signing. In this article we&#8217;ll show how to<strong> send S\/MIME signed email<\/strong> using Mail.dll <a href=\"\\mail\">email component<\/a> and specific signature algorithm (SHA-512).<\/p>\n<p>If you don&#8217;t need to specify signature algorithm you can lean on default values: <a href=\"\/blog\/send-signed-email-using-smime\">send signed email using S\/MIME<\/a>.<\/p>\n<p>Signature algorithm selection is done through <em>Algorithm<\/em> property of the <em>SignatureConfiguration<\/em> class. You can use <em>CommonOids<\/em> class static properties to retrieve common oids (object identifiers):  <em>Sha1<\/em>, <em>Sha256<\/em>, <em>Sha512<\/em>.<\/p>\n<h2>Signing using fluent interface<\/h2>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nIMail mail = Mail.Text(&quot;text&quot;)\r\n    .From(&quot;email@in-the-certificate.com&quot;)\r\n    .SignWith(new SignatureConfiguration(new X509Certificate2(...)) \r\n        { \r\n            Algorithm = CommonOids.Sha512\r\n        })\r\n    .Create();\r\n<\/pre>\n<h2>Signing using MailBuilder<\/h2>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nMailBuilder builder = new MailBuilder();\r\nbuilder.Text = &quot;text&quot;;\r\nbuilder.From.Add(new MailBox(&quot;email@in-the-certificate.com&quot;));\r\nbuilder.SignWith(new SignatureConfiguration(certificate) \r\n    { \r\n        Algorithm = CommonOids.Sha512\r\n    });\r\nIMail mail = builder.Create();\r\n<\/pre>\n<h2>Sending email using SMTP<\/h2>\n<p>Now we can connect to SMTP server and send the email we recently created:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nusing (Smtp client = new Smtp())\r\n{\r\n    client.Connect(&quot;smtp.example.com&quot;); \/\/ or ConnectSSL\r\n    client.UseBestLogin(&quot;user&quot;, &quot;password&quot;);\r\n    client.SendMessage(email);\r\n    client.Close();\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In many cases it is required to use better that standard signing algorithms. With Mail.dll it is easy to specify algorithm that is used for signing. In this article we&#8217;ll show how to send S\/MIME signed email using Mail.dll email component and specific signature algorithm (SHA-512). If you don&#8217;t need to specify signature algorithm you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[15,33,49,50,57],"class_list":["post-3412","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-c","tag-email-component","tag-smime","tag-smtp","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/3412"}],"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=3412"}],"version-history":[{"count":20,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/3412\/revisions"}],"predecessor-version":[{"id":4128,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/3412\/revisions\/4128"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=3412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=3412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=3412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}