I'am writing an application which works with signed mails (S/MIME). In saved message (as ".eml") i see signature part (filename smime.p7s). I need whole this part as a file or stream (for storing in db). How to achieve it?

asked 13 Jan '10, 23:37

Daniel%20Spurny's gravatar image

Daniel Spurny
764
accept rate: 0%

edited 28 Jan '10, 15:20

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.2k18


In Rebex Secure Mail, you can use Rebex.Net.MimeMessage object's SignedContentInfo property to access the raw signature data.

C# sample:

		//using Rebex.Mime;
		//using System.IO;

		// use the low-level MimeMessage class for this
		MimeMessage mail = new MimeMessage();

		// load the message
		mail.Load("message.eml");

		// if it is a signed message...
		if (mail.Kind == MimeEntityKind.Signed)
		{
			// ...extract the "signed content info" part
			// which contains the signature
			byte[] signature = mail.SignedContentInfo.Encode();

			// and save it
			File.WriteAllBytes("smime.p7s", signature);
		}

The high-level Rebex.Net.MailMessage object can't be used for this - it's purpose is to shield the user from the internals :-)

Please be advised that the S/MIME standard also allows an "enveloped" signature variant where the actual content of the message (including any body parts and attachment) is a part of the signature blob. This variant is quite rare, but depending on the kind of input data you need to process, it might be necessary to take this into account when designing our database.


In Rebex Mail (the "unsecure" variant without S/MIME capabilities), the signature part is accessible as an ordinary attachment.

link

answered 14 Jan '10, 11:33

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.2k18
accept rate: 32%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×11
×9
×3

Asked: 13 Jan '10, 23:37

Seen: 512 times

Last updated: 28 Jan '10, 15:20