From f8bf8dc08d1dc77520ad5682a3c15bed288a5984 Mon Sep 17 00:00:00 2001 From: Kai Engert Date: Thu, 6 Jul 2023 10:41:46 +0200 Subject: [PATCH] Bug 1841348 - Avoid an exception when S/MIME certificates cannot be downloaded from LDAP. r=leftmostcat Differential Revision: https://phabricator.services.mozilla.com/D182870 --HG-- extra : rebase_source : a306d170f15c97e8130d352622096b4a545d623d extra : amend_source : 22621704ee02b3cf6890b0caad7a141ae32124b9 --- mailnews/extensions/smime/certFetchingStatus.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mailnews/extensions/smime/certFetchingStatus.js b/mailnews/extensions/smime/certFetchingStatus.js index d0f6810a5a..ea7cd63226 100644 --- a/mailnews/extensions/smime/certFetchingStatus.js +++ b/mailnews/extensions/smime/certFetchingStatus.js @@ -223,9 +223,18 @@ class LDAPMessageListener { } if (Ci.nsILDAPMessage.RES_SEARCH_ENTRY == message.type) { - let outBinValues = message.getBinaryValues(USER_CERT_ATTRIBUTE); - for (let i = 0; i < outBinValues.length; ++i) { - importCert(outBinValues[i]); + let outBinValues = null; + try { + // This call may throw if the result message is empty or doesn't + // contain this attribute. + // It's an allowed condition that the attribute is missing on + // the server, so we silently ignore a failure to obtain it. + outBinValues = message.getBinaryValues(USER_CERT_ATTRIBUTE); + } catch (ex) {} + if (outBinValues) { + for (let i = 0; i < outBinValues.length; ++i) { + importCert(outBinValues[i]); + } } } }