Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

EnvelopedCms class + Decrypting pkcs7-mime Message + The enveloped-data message does not contain the specified recipient.

$
0
0

Hello friends,

I am trying to decrypt an encrypted enveloped message of pkcs7 mime type.

I'm getting two error messages:

Cannot find the certificate and private key for decryption.

The enveloped-data message does not contain the specified recipient.

I would like to decrypt the Enveloped message and figure out the serial number of the certificate it is looking for, the encrypted 3 DES key, and the payload.

Can anyone point me to a code snippet or tutorial on this subject ?

--------------------------------------------------

public static byte[] Decrypt(byte[] encodedEncryptedMessage, string certificateFile, string password)
{
EnvelopedCms envelopedCms = new EnvelopedCms();
envelopedCms.Certificates.Add(new X509Certificate2(certificateFile, password));
envelopedCms.Decode(encodedEncryptedMessage);
envelopedCms.Decrypt();
return envelopedCms.Encode();

}


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>