• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Sign Message

Signs a MIME message with S/MIME.

Code

using System.Security.Cryptography.X509Certificates;
using DRIT.Mail.Rfc.Mime;
using DRIT.Mail.Rfc.SMime;

MimeMessage message = MimeMessage.Load("message.eml");

// Load the signing certificate (with private key)
var certificate = new X509Certificate2("signer.pfx", "password");

var options = new SMimeSignerOptions
{
    Certificate = certificate,
    DigestAlgorithm = SMimeDigestAlgorithm.Sha256,
    DetachedSignature = true,
};

var signer = new SMimeSigner(options);
MimeMessage signed = signer.Sign(message);

signed.Write("signed.eml");

Remarks

SMimeSigner produces a multipart/signed (detached) or opaque signed S/MIME message as defined in RFC 5751. The signing certificate must include a private key and be valid for email signing.

  • Improve this Doc
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX