简体   繁体   English

可以明确定义电子邮件的 S/MIME 内容类型吗?

[英]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".在他们的规范中,在电子邮件附件部分下,他们声明“MIME 部分的内容类型必须是应用程序/八位字节流”。
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;加密消息时,结果 Content-Type 为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联系收件人后,他们能够向我们提供其自动化系统的错误消息,内容为: 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?我在 Rebex 中使用 C# 是否可以强制使用特定的内容类型?

Forcing specific content types is possible using Rebex API (at least in this case), but you have to use the low-level MIME API.使用 Rebex API 可以强制使用特定的内容类型(至少在这种情况下),但您必须使用低级 MIME API。 So if you are currently using the MailMessage class, you might use this approach:因此,如果您当前正在使用MailMessage类,则可以使用以下方法:

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.但是,请注意,这将导致邮件看起来仅包含二进制数据,并且很可能不会被常用邮件软件和库(包括 Rebex Secure Mail)识别为 S/MIME 邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM