當前位置: 首頁>>代碼示例>>C#>>正文


C# MimeMessage.Verify方法代碼示例

本文整理匯總了C#中MimeKit.MimeMessage.Verify方法的典型用法代碼示例。如果您正苦於以下問題:C# MimeMessage.Verify方法的具體用法?C# MimeMessage.Verify怎麽用?C# MimeMessage.Verify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MimeKit.MimeMessage的用法示例。


在下文中一共展示了MimeMessage.Verify方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestDkimSignVerify

		static void TestDkimSignVerify (MimeMessage message, DkimSignatureAlgorithm signatureAlgorithm, DkimCanonicalizationAlgorithm headerAlgorithm, DkimCanonicalizationAlgorithm bodyAlgorithm)
		{
			var headers = new HeaderId[] { HeaderId.From, HeaderId.Subject, HeaderId.Date };
			var signer = CreateSigner (signatureAlgorithm);

			message.Sign (signer, headers, headerAlgorithm, bodyAlgorithm);

			var dkim = message.Headers[0];

			Assert.IsTrue (message.Verify (dkim, new DummyPublicKeyLocator (DkimKeys.Public)), "Failed to verify DKIM-Signature.");

			message.Headers.RemoveAt (0);
		}
開發者ID:jstedfast,項目名稱:MimeKit,代碼行數:13,代碼來源:DkimTests.cs

示例2: TestArgumentExceptions

		public void TestArgumentExceptions ()
		{
			var locator = new DummyPublicKeyLocator (DkimKeys.Public);
			var dkimHeader = new Header (HeaderId.DkimSignature, "value");
			var message = new MimeMessage ();

			Assert.Throws<ArgumentNullException> (() => message.Sign (null, new HeaderId[] { HeaderId.From }));
			Assert.Throws<ArgumentNullException> (() => message.Sign (CreateSigner (DkimSignatureAlgorithm.RsaSha1), null));
			Assert.Throws<ArgumentNullException> (() => message.Verify (null, locator));
			Assert.Throws<ArgumentNullException> (() => message.Verify (dkimHeader, null));
			Assert.Throws<ArgumentNullException> (() => message.Verify (null, dkimHeader, locator));
			Assert.Throws<ArgumentNullException> (() => message.Verify (FormatOptions.Default, null, locator));
			Assert.Throws<ArgumentNullException> (() => message.Verify (FormatOptions.Default, dkimHeader, null));
		}
開發者ID:jstedfast,項目名稱:MimeKit,代碼行數:14,代碼來源:DkimTests.cs

示例3: TestUnicode

		static void TestUnicode (DkimSignatureAlgorithm signatureAlgorithm, DkimCanonicalizationAlgorithm bodyAlgorithm, string expectedHash)
		{
			var headers = new [] { HeaderId.From, HeaderId.To, HeaderId.Subject, HeaderId.Date };
			var signer = CreateSigner (signatureAlgorithm);
			var message = new MimeMessage ();

			message.From.Add (new MailboxAddress ("", "[email protected]"));
			message.To.Add (new MailboxAddress ("", "[email protected]"));
			message.Subject = "This is a unicode message";
			message.Date = DateTimeOffset.Now;

			var builder = new BodyBuilder ();
			builder.TextBody = " تست  ";
			builder.HtmlBody = "  <div> تست </div> ";
			message.Body = builder.ToMessageBody ();

			((Multipart) message.Body).Boundary = "=-MultipartAlternativeBoundary";
			((Multipart) message.Body)[1].ContentId = null;

			message.Body.Prepare (EncodingConstraint.EightBit);

			message.Sign (signer, headers, DkimCanonicalizationAlgorithm.Simple, bodyAlgorithm);

			var dkim = message.Headers[0];

			Console.WriteLine ("{0}", dkim.Value);

			VerifyDkimBodyHash (message, signatureAlgorithm, expectedHash);

			Assert.IsTrue (message.Verify (dkim, new DummyPublicKeyLocator (DkimKeys.Public)), "Failed to verify DKIM-Signature.");
		}
開發者ID:jstedfast,項目名稱:MimeKit,代碼行數:31,代碼來源:DkimTests.cs

示例4: TestEmptyBody

		static void TestEmptyBody (DkimSignatureAlgorithm signatureAlgorithm, DkimCanonicalizationAlgorithm bodyAlgorithm, string expectedHash)
		{
			var headers = new [] { HeaderId.From, HeaderId.To, HeaderId.Subject, HeaderId.Date };
			var signer = CreateSigner (signatureAlgorithm);
			var message = new MimeMessage ();

			message.From.Add (new MailboxAddress ("", "[email protected]"));
			message.To.Add (new MailboxAddress ("", "[email protected]"));
			message.Subject = "This is an empty message";
			message.Date = DateTimeOffset.Now;

			message.Body = new TextPart ("plain") { Text = "" };

			message.Body.Prepare (EncodingConstraint.SevenBit);

			message.Sign (signer, headers, DkimCanonicalizationAlgorithm.Simple, bodyAlgorithm);

			VerifyDkimBodyHash (message, signatureAlgorithm, expectedHash);

			var dkim = message.Headers[0];

			Assert.IsTrue (message.Verify (dkim, new DummyPublicKeyLocator (DkimKeys.Public)), "Failed to verify DKIM-Signature.");
		}
開發者ID:jstedfast,項目名稱:MimeKit,代碼行數:23,代碼來源:DkimTests.cs


注:本文中的MimeKit.MimeMessage.Verify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。