Discussion:
Error decrypting S/MIME messages from Thunderbird
Jeff Stedfast
2013-11-03 17:29:41 UTC
Permalink
Hey all,

I'm having issues when decrypting messages encrypted by Thunderbird with
the following exception:

Org.BouncyCastle.Cms.CmsException: Unexpected object reading content. --->
System.InvalidCastException: Unable to cast object of type
'Org.BouncyCastle.Asn1.DerApplicationSpecific' to type
'Org.BouncyCastle.Asn1.Asn1SequenceParser'.
at Org.BouncyCastle.Cms.CmsContentInfoParser..ctor(Stream data) in
c:\Users\jeff\Documents\Projects\bc-csharp\crypto\src\cms\CMSContentInfoParser.cs:line
26
--- End of inner exception stack trace ---
at Org.BouncyCastle.Cms.CmsContentInfoParser..ctor(Stream data) in
c:\Users\jeff\Documents\Projects\bc-csharp\crypto\src\cms\CMSContentInfoParser.cs:line
34
at Org.BouncyCastle.Cms.CmsEnvelopedDataParser..ctor(Stream
envelopedData) in
c:\Users\jeff\Documents\Projects\bc-csharp\crypto\src\cms\CMSEnvelopedDataParser.cs:line
61
at MimeKit.Cryptography.SecureMimeContext.Decrypt(Stream encryptedData,
IList`1& signatures) in
c:\Users\jeff\Documents\Projects\MimeKit\MimeKit\Cryptography\SecureMimeContext.cs:line
595
at MimeKit.Cryptography.ApplicationPkcs7Mime.Decrypt(CryptographyContext
ctx, IList`1& signatures) in
c:\Users\jeff\Documents\Projects\MimeKit\MimeKit\Cryptography\ApplicationPkcs7Mime.cs:line
145
at UnitTests.SecureMimeTests.TestSecureMimeDecryptThunderbird() in
c:\Users\jeff\Documents\Projects\MimeKit\UnitTests\SecureMimeTests.cs:line
182

Any ideas on this?

Thanks,

Jeff
Jeff Stedfast
2013-11-04 15:45:32 UTC
Permalink
Never mind, I figured out what I was doing wrong in this case.

I had been passing in the undecoded base64 content from the mime part.

Silly goof on my part.

Jeff
Post by Jeff Stedfast
Hey all,
I'm having issues when decrypting messages encrypted by Thunderbird with
Org.BouncyCastle.Cms.CmsException: Unexpected object reading content. --->
System.InvalidCastException: Unable to cast object of type
'Org.BouncyCastle.Asn1.DerApplicationSpecific' to type
'Org.BouncyCastle.Asn1.Asn1SequenceParser'.
at Org.BouncyCastle.Cms.CmsContentInfoParser..ctor(Stream data) in
c:\Users\jeff\Documents\Projects\bc-csharp\crypto\src\cms\CMSContentInfoParser.cs:line
26
--- End of inner exception stack trace ---
at Org.BouncyCastle.Cms.CmsContentInfoParser..ctor(Stream data) in
c:\Users\jeff\Documents\Projects\bc-csharp\crypto\src\cms\CMSContentInfoParser.cs:line
34
at Org.BouncyCastle.Cms.CmsEnvelopedDataParser..ctor(Stream
envelopedData) in
c:\Users\jeff\Documents\Projects\bc-csharp\crypto\src\cms\CMSEnvelopedDataParser.cs:line
61
at MimeKit.Cryptography.SecureMimeContext.Decrypt(Stream encryptedData,
IList`1& signatures) in
c:\Users\jeff\Documents\Projects\MimeKit\MimeKit\Cryptography\SecureMimeContext.cs:line
595
at
MimeKit.Cryptography.ApplicationPkcs7Mime.Decrypt(CryptographyContext ctx,
IList`1& signatures) in
c:\Users\jeff\Documents\Projects\MimeKit\MimeKit\Cryptography\ApplicationPkcs7Mime.cs:line
145
at UnitTests.SecureMimeTests.TestSecureMimeDecryptThunderbird() in
c:\Users\jeff\Documents\Projects\MimeKit\UnitTests\SecureMimeTests.cs:line
182
Any ideas on this?
Thanks,
Jeff
Loading...