public void MultipartSign(MimeMessage message) { // digitally sign our message body using our custom S/MIME cryptography context using (var ctx = new MySecureMimeContext()) { // Note: this assumes that the Sender address has an S/MIME signing certificate // and private key with an X.509 Subject Email identifier that matches the // sender's email address. var sender = message.From.Mailboxes.FirstOrDefault(); message.Body = MultipartSigned.Create(ctx, sender, DigestAlgorithm.Sha1, message.Body); } }
public void MultipartSign(MimeMessage message, X509Certificate2 certificate) { // digitally sign our message body using our custom S/MIME cryptography context using (var ctx = new MySecureMimeContext()) { var signer = new CmsSigner(certificate) { DigestAlgorithm = DigestAlgorithm.Sha1 }; message.Body = MultipartSigned.Create(ctx, signer, message.Body); } }
public void MultipartSign (MimeMessage message) { // digitally sign our message body using our custom S/MIME cryptography context using (var ctx = new MySecureMimeContext ()) { // Note: this assumes that the Sender address has an S/MIME signing certificate // and private key with an X.509 Subject Email identifier that matches the // sender's email address. var sender = message.From.Mailboxes.FirstOrDefault (); message.Body = MultipartSigned.Create (ctx, sender, DigestAlgorithm.Sha1, message.Body); } }
public void Encrypt(MimeMessage message) { // encrypt our message body using our custom S/MIME cryptography context using (var ctx = new MySecureMimeContext()) { // Note: this assumes that each of the recipients has an S/MIME certificate // with an X.509 Subject Email identifier that matches their email address. // // If this is not the case, you can use SecureMailboxAddresses instead of // normal MailboxAddresses which would allow you to specify the fingerprint // of their certificates. You could also choose to use one of the Encrypt() // overloads that take a list of CmsRecipients, instead. message.Body = ApplicationPkcs7Mime.Encrypt(ctx, message.To.Mailboxes, message.Body); } }
public void Encrypt (MimeMessage message) { // encrypt our message body using our custom S/MIME cryptography context using (var ctx = new MySecureMimeContext ()) { // Note: this assumes that each of the recipients has an S/MIME certificate // with an X.509 Subject Email identifier that matches their email address. // // If this is not the case, you can use SecureMailboxAddresses instead of // normal MailboxAddresses which would allow you to specify the fingerprint // of their certificates. You could also choose to use one of the Encrypt() // overloads that take a list of CmsRecipients, instead. message.Body = ApplicationPkcs7Mime.Encrypt (ctx, message.To.Mailboxes, message.Body); } }
public void MultipartSign (MimeMessage message, X509Certificate2 certificate) { // digitally sign our message body using our custom S/MIME cryptography context using (var ctx = new MySecureMimeContext ()) { var signer = new CmsSigner (certificate) { DigestAlgorithm = DigestAlgorithm.Sha1 }; message.Body = MultipartSigned.Create (ctx, signer, message.Body); } }