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();
}