NullReferenceException in Decrypt method

0 votes
asked Sep 15, 2011 by mdibbert (120 points)
edited Oct 11, 2011

I got a problem with the Decrypt method of the Rebex component. I try to decrypt encrypted mails from our customers by calling the MailInfo.Decrypt methods. In most cases, this works fine, but for a small ammout of senders a NullReferenceException is thrown inside the Decrypt() method. The following example method demonstrates how we are using the decrypt method. The stack trace is appended below. Could you tell us, what is causing the exception and how we can fix it? Currently we are using Version 1.0.3588 of the Rebex component.

public void Test(Rebex.Mail.MailMessage mail) {
    if (mail.CanDecrypt) {
        mail.Decrypt(); // null reference exception occurs inside this method

bei Rebex.Security.Certificates.Certificate.Decrypt(Byte[] rgb, Boolean silent) bei Rebex.Security.Cryptography.Pkcs.KeyTransRecipientInfo.720709612(Boolean ) bei Rebex.Security.Cryptography.Pkcs.EnvelopedData.GetSymmetricKey() bei Rebex.Security.Cryptography.Pkcs.EnvelopedData.GetSymmetricAlgorithm() bei Rebex.Security.Cryptography.Pkcs.EnvelopedData.Decrypt() bei Rebex.Mime.MimeEntity.Decrypt() bei Rebex.Mail.MailMessage.Decrypt()

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Sep 15, 2011 by Lukas Pokorny (126,950 points)
edited Sep 15, 2011

This looks like a bug that was fixed in Rebex Secure Mail 1.0.3723.0:

"Fixed a bug in EnvelopedData class that cause a NullReferenceException to be raised when unsupported encryption algorithm is encoutered."

Please try using a newer version of Rebex Secure Mail and let us know whether it solves the issue.