enpsecok
enpsecok

Reputation: 3

Can the S/MIME Content Type of e-mail be explicitly defined?

The recipient expects a signed and encrypted message with attachment.
In their specification, under the e-mail attachment section they state "The Content-Type of the MIME-Parts has to be Application/octet-stream".
Our attachment is of the required content-type. The signed only message contains different content-types but they do not seem to cause any trouble since when sending a signed only message the recipient is able to parse our message and sends an ack.
When encrypting the message the resulting Content-Type is Content-Type: application/pkcs7-mime;.
After contacting the recipient, they were able to provide us with the error message of their automated system which reads: Unknown Email-ContentType: application/pkcs7-mime
Their error message leaves me to believe that other than the attachment-type the e-mail content-type needs to be of octet stream as well.
I'm using C# with Rebex is it possible to force a specific content type?

Upvotes: 0

Views: 298

Answers (1)

Lukas Pokorny
Lukas Pokorny

Reputation: 1558

Forcing specific content types is possible using Rebex API (at least in this case), but you have to use the low-level MIME API. So if you are currently using the MailMessage class, you might use this approach:

using Rebex.Mail;
using Rebex.Mime;
using Rebex.Mime.Headers;
...


var message = new MailMessage();
...
message.Sign(...);
message.Encrypt(...);

MimeMessage mime = message.ToMimeMessage();
mime.ContentType = new ContentType(MediaTypeNames.Application.Octet);
mime.Save("message.eml");

However, be aware that this will result in a message that appears to only contain binary data, and it will most likely not be recognized as an S/MIME message by common mail software and libraries, including Rebex Secure Mail.

Upvotes: 0

Related Questions