Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SignedCms Cms = new SignedCms(new ContentInfo(messageData));
- CmsSigner Signer = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, new X509Certificate2(@"c:\serv.pfx", "123"));
- Cms.ComputeSignature(Signer);
- byte[] SignedBytes = Cms.Encode();
- ContentInfo content = new ContentInfo(SignedBytes);
- EnvelopedCms envelopedCms = new EnvelopedCms(content);
- CmsRecipient recipient = new CmsRecipient(SubjectIdentifierType.SubjectKeyIdentifier, this.certificate);
- envelopedCms.Encrypt(recipient);
- byte[] encryptedBytes = envelopedCms.Encode();
- message.To.Add(new MailAddress(provMail));
- MemoryStream encryptedStream = new MemoryStream(encryptedBytes);
- AlternateView encryptedView = new AlternateView(encryptedStream, "application/pkcs7-mime; smime-type=enveloped-data");
- message.AlternateViews.Add(encryptedView);
- getSmtpConnection().Send(message);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement