// // First sign, THEN encrypt the message // void SignAndEncryptMessage(OutgoingMessage message) { ISmimeCryptographer cryptographer = ResolveOutgoingCryptographer(message.Sender); SignedEntity signedEntity = cryptographer.Sign(message.Message, message.Sender.Certificates); if (m_encryptionEnabled) { // // Encrypt the outbound message with all known trusted certs // MimeEntity encryptedEntity = cryptographer.Encrypt(signedEntity.ToEntity(), message.Recipients.GetCertificates()); // // Alter message content to contain encrypted data // message.Message.UpdateBody(encryptedEntity); } else { message.Message.UpdateBody(signedEntity); } }
public MimeEntity Encrypt(MimeEntity entity, X509Certificate2 encryptingCertificate) { return(m_innerSoftwareCryptographer.Encrypt(entity, encryptingCertificate)); }