Я потратил много времени на поиски хорошей библиотеки S / MIME для .NET, но не повезло. Я закончил тем, что создал свой собственный, под названием OpaqueMail.
Это с открытым исходным кодом и совершенно бесплатно. Он наследуется от класса System.Net.Mail.SmtpClient, поэтому перенос существующего кода является простым. Также включены классы для работы с POP3 и IMAP.
Проверьте это на http://opaquemail.org/.
Пример отправки сообщения S / MIME с тройной упаковкой (с цифровой подписью, шифрованием, затем с цифровой подписью):
// Instantiate a new SMTP connection to Gmail using TLS/SSL protection.
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
smtpClient.Credentials = new NetworkCredential("username@gmail.com", "Pass@word1");
smtpClient.EnableSsl = true;
// Create a new MailMessage class with lorem ipsum.
MailMessage message = new MailMessage("username@gmail.com", "user@example.com", "Example subject", "Lorem ipsum body.");
// Specify that the message should be signed, have its envelope encrypted, and then be signed again (triple-wrapped).
message.SmimeSigned = true;
message.SmimeEncryptedEnvelope = true;
message.SmimeTripleWrapped = true;
// Specify that the message should be timestamped.
message.SmimeSigningOptionFlags = SmimeSigningOptionFlags.SignTime;
// Load the signing certificate from the Local Machine store.
message.SmimeSigningCertificate = CertHelper.GetCertificateBySubjectName(StoreLocation.LocalMachine, "username@gmail.com");
// Send the message.
await smtpClient.SendAsync(message);
Надеюсь, это поможет.