Closed Bug 1707517 Opened 4 years ago Closed 2 years ago

Thunderbird sometimes fails to send or save SMIME signed mails: NS_ERROR_FAILURE, nsIMsgComposeSecure.finishCryptoEncapsulation, MimeMessage.jsm:86

Categories

(MailNews Core :: Security: S/MIME, defect, P2)

Thunderbird 89

Tracking

(thunderbird_esr78 unaffected)

RESOLVED WORKSFORME
Tracking Status
thunderbird_esr78 --- unaffected

People

(Reporter: r0bcas7, Unassigned, NeedInfo)

Details

(Keywords: regression)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0

Steps to reproduce:

I try to send or save or auto-save an email with a SMIME signature.

Sending signed emails works most of the time. It sometimes stops working and only a restart of Thunderbird will help.

This happens on Thunderbird 89b1 (and earlier) on macOS 11 (M1).

Actual results:

I get an error message and the email is not sent or saved.

The message is:
Unable to save your message as a draft.
Unable to sign message. Please check that the certificates specified in Mail & Newsgroups Account Settings for this mail account are valid and trusted for mail.

In the error log I see:
mailnews.send:
Exception { name: "NS_ERROR_FAILURE", message: "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgComposeSecure.finishCryptoEncapsulation]", result: 2147500037, filename: "resource:///modules/MimeMessage.jsm", lineNumber: 86, columnNumber: 0, data: null, stack: "createMessageFile@resource:///modules/MimeMessage.jsm:86:27\n", location: XPCWrappedNative_NoHelper }

Expected results:

The email should be sent or saved.

Summary: Thunderbird stops sending or saving SMIME signed mails → Thunderbird sometimes fails to send or save SMIME signed mails: NS_ERROR_FAILURE, nsIMsgComposeSecure.finishCryptoEncapsulation, MimeMessage.jsm:86

Let's have a permalink for the error so that we don't miss that in case we only get to this later...

https://searchfox.org/comm-central/rev/657a062139cbb8e35e064a2df07eb1749229a5e9/mailnews/compose/src/MimeMessage.jsm#86

  async createMessageFile() {
    [*snip*]
    this._composeSecure = this._getComposeSecure();
    if (this._composeSecure) {
      await this._writePart(topPart);
      this._composeSecure.finishCryptoEncapsulation(false, this._sendReport);   // <-- line 86 where the error occurs
    } else {
      await this._writePart(topPart);
    }
    [*snip*]
  }
Severity: -- → S2
Priority: -- → P2

Still broken in TB 89.0b3.

Still broken in TB 90.0b1.

This is still broken for me in TB91b1. Does this mean this bug ships unfixed in TB90ESR?

Why is the status still "unconfirmed"?

Is there anything I can do to help this bug getting fixed?

mailnews.send:
Exception { name: "NS_ERROR_FAILURE", message: "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgComposeSecure.finishCryptoEncapsulation]", result: 2147500037, filename: "resource:///modules/MimeMessage.jsm", lineNumber: 86, columnNumber: 0, data: null, stack: "createMessageFile@resource:///modules/MimeMessage.jsm:86:27\n", location: XPCWrappedNative_NoHelper }

MessageSend.jsm:122:27

Sending signed emails works most of the time. It sometimes stops working and only a restart of Thunderbird will help.

Do you happen to find a way that can always reproduce it?

(In reply to Ping Chen (:rnons) from comment #5)

Sending signed emails works most of the time. It sometimes stops working and only a restart of Thunderbird will help.

Do you happen to find a way that can always reproduce it?

Sadly not. I am using TB-beta as my daily mail agent (since it is the only native ARM-Mac version) and it is not a well-controlled environment.

In most cases I get an error when TB tries to autosave an open compose window (I use an S-MIME signature by default) and then I can neither send or save this email unless I switch off signing.

Have you tried unchecking the "Store draft messages in encrypted format" option in "End-To-End Encryption" setting? That doesn't fix the root problem, but we may get an idea of how often it happens during sending.

(In reply to Ping Chen (:rnons) from comment #7)

Have you tried unchecking the "Store draft messages in encrypted format" option in "End-To-End Encryption" setting? That doesn't fix the root problem, but we may get an idea of how often it happens during sending.

Thanks for the tip. I'll try that and see how often the error occurs on sending alone.

Is there anything obvious I can try to do to help debugging when the error occurs?

I disabled "store draft in encrypted format" and I can still save the drafts now but I still get occasional errors on sending S-MIME signed emails.

Today on TB91b3 I first noticed that checking the signature on other (correctly signed) mails failed and I found the following error in the log:

TypeError: currUrl is null
isCurrentMessage chrome://openpgp/content/ui/enigmailMsgHdrViewOverlay.js:934
handleSMimeMessage chrome://openpgp/content/ui/enigmailMsgHdrViewOverlay.js:1244
handleSmime chrome://openpgp/content/modules/pgpmimeHandler.jsm:240
onStartRequest chrome://openpgp/content/modules/pgpmimeHandler.jsm:202
enigmailMsgHdrViewOverlay.js:934:1

Then I tried to send a signed email and that failed as well with

mailnews.send:
Exception { name: "NS_ERROR_FAILURE", message: "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgComposeSecure.finishCryptoEncapsulation]", result: 2147500037, filename: "resource:///modules/MimeMessage.jsm", lineNumber: 86, columnNumber: 0, data: null, stack: "createMessageFile@resource:///modules/MimeMessage.jsm:86:27\n", location: XPCWrappedNative_NoHelper }
createAndSendMessage resource:///modules/MessageSend.jsm:122

(In reply to Robert Casties from comment #9)

TypeError: currUrl is null

This shouldn't cause this bug. That code is executing in the scope of the message viewer windows - not in the composer window scope.

Filed bug 1722097 for the issue from comment 10.

If this is difficult to reproduce, my only idea is to provide you with a special build that uses special logging.
The failure probably happens inside nsMsgComposeSecure::MimeFinishMultipartSigned which is a large function with many actions, and each of them could potentially produce the failure you get.

I would run a client with additional logging (MacOS ARM64) if there is a special build I can try or if I can configure an existing TB build.

I'm not sure if this is the same issue or a new bug, but after upgrading to Thunderbird 92.0b3, I started getting the same error with the same error in the log on macOS Catalina on Intel. The same thing also happens in 92.0b4. I did not have that problem in 92.0b2. It only happens with S/MIME and not with OpenPGP.

Exception { name: "NS_ERROR_FAILURE", message: "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgComposeSecure.beginCryptoEncapsulation]", result: 2147500037, filename: "resource:///modules/MimeMessage.jsm", lineNumber: 457, columnNumber: 0, data: null, stack: "_startCryptoEncapsulation@resource:///modules/MimeMessage.jsm:457:25\n_writePart@resource:///modules/MimeMessage.jsm:502:12\n", location: XPCWrappedNative_NoHelper }
​
columnNumber: 0
​
data: null
​
filename: "resource:///modules/MimeMessage.jsm"
​
lineNumber: 457
​
location: XPCWrappedNative_NoHelper { QueryInterface: QueryInterface(), filename: Getter, name: Getter, … }
​
message: "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgComposeSecure.beginCryptoEncapsulation]"
​
name: "NS_ERROR_FAILURE"
​
result: 2147500037
​
stack: "_startCryptoEncapsulation@resource:///modules/MimeMessage.jsm:457:25\n_writePart@resource:///modules/MimeMessage.jsm:502:12\n"
​
<prototype>: ExceptionPrototype { toString: toString(), name: Getter, message: Getter, … }
MessageSend.jsm:122:27
    createAndSendMessage resource:///modules/MessageSend.jsm:122

hello,
had exactly the same problem and log:
using thunderbird 91.4.0 on fedora 35/gnome/wayland.
and in case this could also be usefull:
Acer Aspire V3-371 / Intel® Core™ i5-4210U CPU @ 1.70GHz
all softwares and keyboard in french

mailnews.send:
Exception { name: "NS_ERROR_FAILURE", message: "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgComposeSecure.beginCryptoEncapsulation]", result: 2147500037, filename: "resource:///modules/MimeMessage.jsm", lineNumber: 457, columnNumber: 0, data: null, stack: "_startCryptoEncapsulation@resource:///modules/MimeMessage.jsm:457:25\n_writePart@resource:///modules/MimeMessage.jsm:502:12\n", location: XPCWrappedNative_NoHelper }
​columnNumber: 0
​data: null
​filename: "resource:///modules/MimeMessage.jsm"
​lineNumber: 457
​location: XPCWrappedNative_NoHelper { QueryInterface: QueryInterface(), filename: Getter, name: Getter, … }
​message: "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgComposeSecure.beginCryptoEncapsulation]"
​name: "NS_ERROR_FAILURE"
​result: 2147500037
​stack: "_startCryptoEncapsulation@resource:///modules/MimeMessage.jsm:457:25\n_writePart@resource:///modules/MimeMessage.jsm:502:12\n"
​<prototype>: ExceptionPrototype { toString: toString(), name: Getter, message: Getter, … }
MessageSend.jsm:122:27
createAndSendMessage resource:///modules/MessageSend.jsm:122

the problem occurs if I try to send a message in html or simple text, with or without signature. no accents or special character in the message (simple ascii)

hope this can help.
I could find a way to make it work.

Robert, are you still seeing this on beta?

If so, then it is time to request this of Kai ...

(In reply to Kai Engert (:KaiE:) from comment #12)

If this is difficult to reproduce, my only idea is to provide you with a special build that uses special logging.

Flags: needinfo?(r0bcas7)

I haven't seen this problem for some months now. I am on the release channel on the ARM version of macOS, currently TB 91.5.1 on macOS 12.2 on M1.

I am not sure if I created a new profile when I switched from beta to the 91 release channel when that started to have Mac-ARM support.

Hi all,

I have the same issue with TB 91.5.0 (64-Bit) (on Ubuntu 21.10, (Kernel 5.13.0-23-generic)

mailnews.send:
Exception { name: "NS_ERROR_FAILURE", message: "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgComposeSecure.beginCryptoEncapsulation]", result: 2147500037, filename: "resource:///modules/MimeMessage.jsm", lineNumber: 457, columnNumber: 0, data: null, stack: "_startCryptoEncapsulation@resource:///modules/MimeMessage.jsm:457:25\n_writePart@resource:///modules/MimeMessage.jsm:502:12\n", location: XPCWrappedNative_NoHelper }
MessageSend.jsm:131:27

I added brand new S/MIME Certificates for the first time and every time I try to send an email now (Digitally Signed!) I just see this generic error message. In the error-console I can see the above. Let me know if I can help i.e. add more info.

BR,
Marco

Hi all,

I was able to solve my issue: I had to install the root-certificates (and had to double-check all of the interim-certificates can be used for email-users) and had to re-configure the email-profile to use the certs, and all were fine.

Hope this helps!

BR,
Marco

Upgraded to TB 102.0 on my MacOS 12.4 and a working S/MIME situation now suddenly turned into this; I cannot send S/MIME signed messages anymore.

"Unable to sign message. Please check that the certificates specified in Mail & Newsgroups Account Settings for this mail account are valid and trusted for mail."

mdavids, for the new issue with thunderbird 102.0, please see bug 1777336 - a workaround is described on the whiteboard.

I'm resolving this original bug, because of comment 19.

Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.