Bug 1435093 - Port bug 1421084 to mailnews: remove nsNSSShutDownPreventionLock, isAlreadyShutDown, shutdown, virtualDestroyNSSReference, nsNSSShutDown.h from mailnews. rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Fri, 02 Feb 2018 01:03:12 +0100
changeset 31026 113fa182b10b573cd66d000f77d0e351c04e62ec
parent 31025 8439e50b3e6c94f1891b1e67364da5b0a1778e69
child 31027 e62f73758e138743a47f2682f721862f09cd89c4
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersbustage-fix
bugs1435093, 1421084
Bug 1435093 - Port bug 1421084 to mailnews: remove nsNSSShutDownPreventionLock, isAlreadyShutDown, shutdown, virtualDestroyNSSReference, nsNSSShutDown.h from mailnews. rs=bustage-fix
mailnews/extensions/smime/src/nsCertPicker.cpp
mailnews/extensions/smime/src/nsCertPicker.h
mailnews/mime/src/nsCMS.cpp
mailnews/mime/src/nsCMS.h
mailnews/mime/src/nsCMSSecureMessage.cpp
--- a/mailnews/extensions/smime/src/nsCertPicker.cpp
+++ b/mailnews/extensions/smime/src/nsCertPicker.cpp
@@ -17,17 +17,16 @@
 #include "nsIServiceManager.h"
 #include "nsIX509CertValidity.h"
 #include "nsMemory.h"
 #include "nsMsgComposeSecure.h"
 #include "nsNSSCertificate.h"
 #include "nsNSSComponent.h"
 #include "nsNSSDialogHelper.h"
 #include "nsNSSHelper.h"
-#include "nsNSSShutDown.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include "pkix/pkixtypes.h"
 
 using namespace mozilla;
 
 MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueCERTCertNicknames,
                                       CERTCertNicknames,
@@ -227,22 +226,16 @@ FormatUIStrings(nsIX509Cert* cert, const
 NS_IMPL_ISUPPORTS(nsCertPicker, nsICertPickDialogs, nsIUserCertPicker)
 
 nsCertPicker::nsCertPicker()
 {
 }
 
 nsCertPicker::~nsCertPicker()
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown()) {
-    return;
-  }
-
-  shutdown(ShutdownCalledFrom::Object);
 }
 
 nsresult
 nsCertPicker::Init()
 {
   nsresult rv;
   nsCOMPtr<nsISupports> psm = do_GetService("@mozilla.org/psm;1", &rv);
   return rv;
@@ -304,21 +297,16 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(
                                         const char16_t *selectedNickname,
                                         int32_t certUsage,
                                         bool allowInvalid,
                                         bool allowDuplicateNicknames,
                                         const nsAString &emailAddress,
                                         bool *canceled,
                                         nsIX509Cert **_retval)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown()) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
   int32_t selectedIndex = -1;
   bool selectionFound = false;
   char16_t **certNicknameList = nullptr;
   char16_t **certDetailsList = nullptr;
   CERTCertListNode* node = nullptr;
   nsresult rv = NS_OK;
 
   {
--- a/mailnews/extensions/smime/src/nsCertPicker.h
+++ b/mailnews/extensions/smime/src/nsCertPicker.h
@@ -3,34 +3,28 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsCertPicker_h
 #define nsCertPicker_h
 
 #include "nsICertPickDialogs.h"
 #include "nsIUserCertPicker.h"
-#include "nsNSSShutDown.h"
 
 #define NS_CERT_PICKER_CID \
   { 0x735959a1, 0xaf01, 0x447e, { 0xb0, 0x2d, 0x56, 0xe9, 0x68, 0xfa, 0x52, 0xb4 } }
 
 class nsCertPicker : public nsICertPickDialogs
                    , public nsIUserCertPicker
-                   , public nsNSSShutDownObject
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSICERTPICKDIALOGS
   NS_DECL_NSIUSERCERTPICKER
 
   nsCertPicker();
-
-  // Nothing to actually release.
-  virtual void virtualDestroyNSSReference() override {}
-
   nsresult Init();
 
 protected:
   virtual ~nsCertPicker();
 };
 
 #endif // nsCertPicker_h
--- a/mailnews/mime/src/nsCMS.cpp
+++ b/mailnews/mime/src/nsCMS.cpp
@@ -42,54 +42,40 @@ nsCMSMessage::nsCMSMessage()
 }
 nsCMSMessage::nsCMSMessage(NSSCMSMessage *aCMSMsg)
 {
   m_cmsMsg = aCMSMsg;
 }
 
 nsCMSMessage::~nsCMSMessage()
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown()) {
-    return;
-  }
   destructorSafeDestroyNSSReference();
-  shutdown(ShutdownCalledFrom::Object);
 }
 
 nsresult nsCMSMessage::Init()
 {
   nsresult rv;
   nsCOMPtr<nsISupports> nssInitialized = do_GetService("@mozilla.org/psm;1", &rv);
   return rv;
 }
 
-void nsCMSMessage::virtualDestroyNSSReference()
-{
-  destructorSafeDestroyNSSReference();
-}
-
 void nsCMSMessage::destructorSafeDestroyNSSReference()
 {
   if (m_cmsMsg) {
     NSS_CMSMessage_Destroy(m_cmsMsg);
   }
 }
 
 NS_IMETHODIMP nsCMSMessage::VerifySignature()
 {
   return CommonVerifySignature(nullptr, 0);
 }
 
 NSSCMSSignerInfo* nsCMSMessage::GetTopLevelSignerInfo()
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return nullptr;
-
   if (!m_cmsMsg)
     return nullptr;
 
   if (!NSS_CMSMessage_IsSigned(m_cmsMsg))
     return nullptr;
 
   NSSCMSContentInfo *cinfo = NSS_CMSMessage_ContentLevel(m_cmsMsg, 0);
   if (!cinfo)
@@ -100,88 +86,68 @@ NSSCMSSignerInfo* nsCMSMessage::GetTopLe
     return nullptr;
 
   PR_ASSERT(NSS_CMSSignedData_SignerInfoCount(sigd) > 0);
   return NSS_CMSSignedData_GetSignerInfo(sigd, 0);
 }
 
 NS_IMETHODIMP nsCMSMessage::GetSignerEmailAddress(char * * aEmail)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::GetSignerEmailAddress\n"));
   NS_ENSURE_ARG(aEmail);
 
   NSSCMSSignerInfo *si = GetTopLevelSignerInfo();
   if (!si)
     return NS_ERROR_FAILURE;
 
   *aEmail = NSS_CMSSignerInfo_GetSignerEmailAddress(si);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsCMSMessage::GetSignerCommonName(char ** aName)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::GetSignerCommonName\n"));
   NS_ENSURE_ARG(aName);
 
   NSSCMSSignerInfo *si = GetTopLevelSignerInfo();
   if (!si)
     return NS_ERROR_FAILURE;
 
   *aName = NSS_CMSSignerInfo_GetSignerCommonName(si);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsCMSMessage::ContentIsEncrypted(bool *isEncrypted)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::ContentIsEncrypted\n"));
   NS_ENSURE_ARG(isEncrypted);
 
   if (!m_cmsMsg)
     return NS_ERROR_FAILURE;
 
   *isEncrypted = NSS_CMSMessage_IsEncrypted(m_cmsMsg);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsCMSMessage::ContentIsSigned(bool *isSigned)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::ContentIsSigned\n"));
   NS_ENSURE_ARG(isSigned);
 
   if (!m_cmsMsg)
     return NS_ERROR_FAILURE;
 
   *isSigned = NSS_CMSMessage_IsSigned(m_cmsMsg);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsCMSMessage::GetSignerCert(nsIX509Cert **scert)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   NSSCMSSignerInfo *si = GetTopLevelSignerInfo();
   if (!si)
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIX509Cert> cert;
   if (si->cert) {
     MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::GetSignerCert got signer cert\n"));
 
@@ -214,20 +180,16 @@ NS_IMETHODIMP nsCMSMessage::VerifyDetach
   if (!aDigestData || !aDigestDataLen)
     return NS_ERROR_FAILURE;
 
   return CommonVerifySignature(aDigestData, aDigestDataLen);
 }
 
 nsresult nsCMSMessage::CommonVerifySignature(unsigned char* aDigestData, uint32_t aDigestDataLen)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::CommonVerifySignature, content level count %d\n", NSS_CMSMessage_ContentLevelCount(m_cmsMsg)));
   NSSCMSContentInfo *cinfo = nullptr;
   NSSCMSSignedData *sigd = nullptr;
   NSSCMSSignerInfo *si;
   int32_t nsigners;
   RefPtr<SharedCertVerifier> certVerifier;
   nsresult rv = NS_ERROR_FAILURE;
 
@@ -378,17 +340,16 @@ public:
   {
     MOZ_ASSERT(NS_IsMainThread());
     mMessage = aMessage;
     mListener = aListener;
     mDigestData.Assign(reinterpret_cast<char *>(aDigestData), aDigestDataLen);
   }
 
 private:
-  virtual void ReleaseNSSResources() override {}
   virtual nsresult CalculateResult() override
   {
     MOZ_ASSERT(!NS_IsMainThread());
 
     nsresult rv;
     if (!mDigestData.IsEmpty()) {
       rv = mMessage->VerifyDetachedSignature(
         reinterpret_cast<uint8_t*>(const_cast<char *>(mDigestData.get())),
@@ -414,36 +375,26 @@ private:
 
 nsresult nsCMSMessage::CommonAsyncVerifySignature(nsISMimeVerificationListener *aListener,
                                                   unsigned char* aDigestData, uint32_t aDigestDataLen)
 {
   RefPtr<CryptoTask> task = new SMimeVerificationTask(this, aListener, aDigestData, aDigestDataLen);
   return task->Dispatch("SMimeVerify");
 }
 
-class nsZeroTerminatedCertArray : public nsNSSShutDownObject
+class nsZeroTerminatedCertArray
 {
 public:
   nsZeroTerminatedCertArray()
   :mCerts(nullptr), mPoolp(nullptr), mSize(0)
   {
   }
 
   ~nsZeroTerminatedCertArray()
   {
-    nsNSSShutDownPreventionLock locker;
-    if (isAlreadyShutDown()) {
-      return;
-    }
-    destructorSafeDestroyNSSReference();
-    shutdown(ShutdownCalledFrom::Object);
-  }
-
-  void virtualDestroyNSSReference()
-  {
     destructorSafeDestroyNSSReference();
   }
 
   void destructorSafeDestroyNSSReference()
   {
     if (mCerts)
     {
       for (uint32_t i=0; i < mSize; i++) {
@@ -483,63 +434,47 @@ public:
       mCerts[i] = nullptr;
     }
 
     return true;
   }
 
   void set(uint32_t i, CERTCertificate *c)
   {
-    nsNSSShutDownPreventionLock locker;
-    if (isAlreadyShutDown())
-      return;
-
     if (i >= mSize)
       return;
 
     if (mCerts[i]) {
       CERT_DestroyCertificate(mCerts[i]);
     }
 
     mCerts[i] = CERT_DupCertificate(c);
   }
 
   CERTCertificate *get(uint32_t i)
   {
-    nsNSSShutDownPreventionLock locker;
-    if (isAlreadyShutDown())
-      return nullptr;
-
     if (i >= mSize)
       return nullptr;
 
     return CERT_DupCertificate(mCerts[i]);
   }
 
   CERTCertificate **getRawArray()
   {
-    nsNSSShutDownPreventionLock locker;
-    if (isAlreadyShutDown())
-      return nullptr;
-
     return mCerts;
   }
 
 private:
   CERTCertificate **mCerts;
   PLArenaPool *mPoolp;
   uint32_t mSize;
 };
 
 NS_IMETHODIMP nsCMSMessage::CreateEncrypted(nsIArray * aRecipientCerts)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::CreateEncrypted\n"));
   NSSCMSContentInfo *cinfo;
   NSSCMSEnvelopedData *envd;
   NSSCMSRecipientInfo *recipientInfo;
   nsZeroTerminatedCertArray recipientCerts;
   SECOidTag bulkAlgTag;
   int keySize;
   uint32_t i;
@@ -620,20 +555,16 @@ loser:
 }
 
 NS_IMETHODIMP
 nsCMSMessage::CreateSigned(nsIX509Cert* aSigningCert, nsIX509Cert* aEncryptCert,
                            unsigned char* aDigestData, uint32_t aDigestDataLen,
                            int16_t aDigestType)
 {
   NS_ENSURE_ARG(aSigningCert);
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::CreateSigned\n"));
   NSSCMSContentInfo *cinfo;
   NSSCMSSignedData *sigd;
   NSSCMSSignerInfo *signerinfo;
   UniqueCERTCertificate scert(aSigningCert->GetCert());
   UniqueCERTCertificate ecert;
   nsresult rv = NS_ERROR_FAILURE;
 
@@ -781,81 +712,59 @@ NS_IMPL_ISUPPORTS(nsCMSDecoder, nsICMSDe
 
 nsCMSDecoder::nsCMSDecoder()
 : m_dcx(nullptr)
 {
 }
 
 nsCMSDecoder::~nsCMSDecoder()
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown()) {
-    return;
-  }
   destructorSafeDestroyNSSReference();
-  shutdown(ShutdownCalledFrom::Object);
 }
 
 nsresult nsCMSDecoder::Init()
 {
   nsresult rv;
   nsCOMPtr<nsISupports> nssInitialized = do_GetService("@mozilla.org/psm;1", &rv);
   return rv;
 }
 
-void nsCMSDecoder::virtualDestroyNSSReference()
-{
-  destructorSafeDestroyNSSReference();
-}
-
 void nsCMSDecoder::destructorSafeDestroyNSSReference()
 {
   if (m_dcx) {
     NSS_CMSDecoder_Cancel(m_dcx);
     m_dcx = nullptr;
   }
 }
 
 /* void start (in NSSCMSContentCallback cb, in voidPtr arg); */
 NS_IMETHODIMP nsCMSDecoder::Start(NSSCMSContentCallback cb, void * arg)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSDecoder::Start\n"));
   m_ctx = new PipUIContext();
 
   m_dcx = NSS_CMSDecoder_Start(0, cb, arg, 0, m_ctx, 0, 0);
   if (!m_dcx) {
     MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSDecoder::Start - can't start decoder\n"));
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 /* void update (in string bug, in long len); */
 NS_IMETHODIMP nsCMSDecoder::Update(const char *buf, int32_t len)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSDecoder::Update\n"));
   NSS_CMSDecoder_Update(m_dcx, (char *)buf, len);
   return NS_OK;
 }
 
 /* void finish (); */
 NS_IMETHODIMP nsCMSDecoder::Finish(nsICMSMessage ** aCMSMsg)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSDecoder::Finish\n"));
   NSSCMSMessage *cmsMsg;
   cmsMsg = NSS_CMSDecoder_Finish(m_dcx);
   m_dcx = nullptr;
   if (cmsMsg) {
     nsCMSMessage *obj = new nsCMSMessage(cmsMsg);
     // The NSS object cmsMsg still carries a reference to the context
     // we gave it on construction.
@@ -870,95 +779,69 @@ NS_IMPL_ISUPPORTS(nsCMSEncoder, nsICMSEn
 
 nsCMSEncoder::nsCMSEncoder()
 : m_ecx(nullptr)
 {
 }
 
 nsCMSEncoder::~nsCMSEncoder()
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown()) {
-    return;
-  }
   destructorSafeDestroyNSSReference();
-  shutdown(ShutdownCalledFrom::Object);
 }
 
 nsresult nsCMSEncoder::Init()
 {
   nsresult rv;
   nsCOMPtr<nsISupports> nssInitialized = do_GetService("@mozilla.org/psm;1", &rv);
   return rv;
 }
 
-void nsCMSEncoder::virtualDestroyNSSReference()
-{
-  destructorSafeDestroyNSSReference();
-}
-
 void nsCMSEncoder::destructorSafeDestroyNSSReference()
 {
   if (m_ecx)
     NSS_CMSEncoder_Cancel(m_ecx);
 }
 
 /* void start (); */
 NS_IMETHODIMP nsCMSEncoder::Start(nsICMSMessage *aMsg, NSSCMSContentCallback cb, void * arg)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSEncoder::Start\n"));
   nsCMSMessage *cmsMsg = static_cast<nsCMSMessage*>(aMsg);
   m_ctx = new PipUIContext();
 
   m_ecx = NSS_CMSEncoder_Start(cmsMsg->getCMS(), cb, arg, 0, 0, 0, m_ctx, 0, 0, 0, 0);
   if (!m_ecx) {
     MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSEncoder::Start - can't start encoder\n"));
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 /* void update (in string aBuf, in long aLen); */
 NS_IMETHODIMP nsCMSEncoder::Update(const char *aBuf, int32_t aLen)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSEncoder::Update\n"));
   if (!m_ecx || NSS_CMSEncoder_Update(m_ecx, aBuf, aLen) != SECSuccess) {
     MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSEncoder::Update - can't update encoder\n"));
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 /* void finish (); */
 NS_IMETHODIMP nsCMSEncoder::Finish()
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   nsresult rv = NS_OK;
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSEncoder::Finish\n"));
   if (!m_ecx || NSS_CMSEncoder_Finish(m_ecx) != SECSuccess) {
     MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSEncoder::Finish - can't finish encoder\n"));
     rv = NS_ERROR_FAILURE;
   }
   m_ecx = nullptr;
   return rv;
 }
 
 /* void encode (in nsICMSMessage aMsg); */
 NS_IMETHODIMP nsCMSEncoder::Encode(nsICMSMessage *aMsg)
 {
-  nsNSSShutDownPreventionLock locker;
-  if (isAlreadyShutDown())
-    return NS_ERROR_NOT_AVAILABLE;
-
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSEncoder::Encode\n"));
   return NS_ERROR_NOT_IMPLEMENTED;
 }
--- a/mailnews/mime/src/nsCMS.h
+++ b/mailnews/mime/src/nsCMS.h
@@ -11,24 +11,22 @@
 #include "nsIInterfaceRequestor.h"
 #include "nsICMSMessage.h"
 #include "nsICMSMessage2.h"
 #include "nsIX509Cert.h"
 #include "nsICMSEncoder.h"
 #include "nsICMSDecoder.h"
 #include "sechash.h"
 #include "cms.h"
-#include "nsNSSShutDown.h"
 
 #define NS_CMSMESSAGE_CID \
   { 0xa4557478, 0xae16, 0x11d5, { 0xba,0x4b,0x00,0x10,0x83,0x03,0xb1,0x17 } }
 
 class nsCMSMessage : public nsICMSMessage,
-                     public nsICMSMessage2,
-                     public nsNSSShutDownObject
+                     public nsICMSMessage2
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSICMSMESSAGE
   NS_DECL_NSICMSMESSAGE2
 
   nsCMSMessage();
   nsCMSMessage(NSSCMSMessage* aCMSMsg);
@@ -41,63 +39,58 @@ private:
   nsCOMPtr<nsIInterfaceRequestor> m_ctx;
   NSSCMSMessage * m_cmsMsg;
   NSSCMSSignerInfo* GetTopLevelSignerInfo();
   nsresult CommonVerifySignature(unsigned char* aDigestData, uint32_t aDigestDataLen);
 
   nsresult CommonAsyncVerifySignature(nsISMimeVerificationListener *aListener,
                                       unsigned char* aDigestData, uint32_t aDigestDataLen);
 
-  virtual void virtualDestroyNSSReference() override;
   void destructorSafeDestroyNSSReference();
 
 };
 
 // ===============================================
 // nsCMSDecoder - implementation of nsICMSDecoder
 // ===============================================
 
 #define NS_CMSDECODER_CID \
   { 0x9dcef3a4, 0xa3bc, 0x11d5, { 0xba, 0x47, 0x00, 0x10, 0x83, 0x03, 0xb1, 0x17 } }
 
-class nsCMSDecoder : public nsICMSDecoder,
-                     public nsNSSShutDownObject
+class nsCMSDecoder : public nsICMSDecoder
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSICMSDECODER
 
   nsCMSDecoder();
   nsresult Init();
 
 private:
   virtual ~nsCMSDecoder();
   nsCOMPtr<nsIInterfaceRequestor> m_ctx;
   NSSCMSDecoderContext *m_dcx;
-  virtual void virtualDestroyNSSReference() override;
   void destructorSafeDestroyNSSReference();
 };
 
 // ===============================================
 // nsCMSEncoder - implementation of nsICMSEncoder
 // ===============================================
 
 #define NS_CMSENCODER_CID \
   { 0xa15789aa, 0x8903, 0x462b, { 0x81, 0xe9, 0x4a, 0xa2, 0xcf, 0xf4, 0xd5, 0xcb } }
-class nsCMSEncoder : public nsICMSEncoder,
-                     public nsNSSShutDownObject
+class nsCMSEncoder : public nsICMSEncoder
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSICMSENCODER
 
   nsCMSEncoder();
   nsresult Init();
 
 private:
   virtual ~nsCMSEncoder();
   nsCOMPtr<nsIInterfaceRequestor> m_ctx;
   NSSCMSEncoderContext *m_ecx;
-  virtual void virtualDestroyNSSReference() override;
   void destructorSafeDestroyNSSReference();
 };
 
 #endif
--- a/mailnews/mime/src/nsCMSSecureMessage.cpp
+++ b/mailnews/mime/src/nsCMSSecureMessage.cpp
@@ -16,17 +16,16 @@
 #include "nsDependentSubstring.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsServiceManagerUtils.h"
 #include "nsISupports.h"
 #include "nsIX509Cert.h"
 #include "nsIX509CertDB.h"
 #include "nsNSSComponent.h"
 #include "nsNSSHelper.h"
-#include "nsNSSShutDown.h"
 #include "plbase64.h"
 
 #ifdef PR_LOGGING
 extern mozilla::LazyLogModule gPIPNSSLog;
 #endif
 
 using namespace mozilla;
 using namespace mozilla::psm;
@@ -92,17 +91,16 @@ NS_IMETHODIMP nsCMSSecureMessage::CanBeU
 NS_IMETHODIMP nsCMSSecureMessage::CanBeUsedForEmailSigning(nsIX509Cert* aCert, bool* aCanBeUsed) {
   return CheckUsageOk(aCert, certificateUsageEmailSigner, aCanBeUsed);
 }
 
 // nsCMSSecureMessage::DecodeCert
 NS_IMETHODIMP nsCMSSecureMessage::
 DecodeCert(const char *value, nsIX509Cert ** _retval)
 {
-  nsNSSShutDownPreventionLock locker;
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSSecureMessage::DecodeCert\n"));
   nsresult rv = NS_OK;
   int32_t length;
   unsigned char *data = 0;
 
   *_retval = 0;
 
   if (!value) { return NS_ERROR_FAILURE; }
@@ -132,17 +130,16 @@ DecodeCert(const char *value, nsIX509Cer
 // nsCMSSecureMessage::SendMessage
 // Don't clash with Bill's versions SendMessageA or SendMessageW.
 #if defined (_MSC_VER)
 #undef SendMessage
 #endif
 NS_IMETHODIMP nsCMSSecureMessage::
 SendMessage(const char *msg, const char *base64Cert, char ** _retval)
 {
-  nsNSSShutDownPreventionLock locker;
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSSecureMessage::SendMessage\n"));
   nsresult rv = NS_OK;
   CERTCertificate *cert = 0;
   NSSCMSMessage *cmsMsg = 0;
   unsigned char *certDER = 0;
   int32_t derLen;
   NSSCMSEnvelopedData *env;
   NSSCMSContentInfo *cinfo;
@@ -256,17 +253,16 @@ done:
 }
 
 /*
  * nsCMSSecureMessage::ReceiveMessage
  */
 NS_IMETHODIMP nsCMSSecureMessage::
 ReceiveMessage(const char *msg, char **_retval)
 {
-  nsNSSShutDownPreventionLock locker;
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSSecureMessage::ReceiveMessage\n"));
   nsresult rv = NS_OK;
   NSSCMSDecoderContext *dcx;
   unsigned char *der = 0;
   int32_t derLen;
   NSSCMSMessage *cmsMsg = 0;
   SECItem *content;
   nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();