2001-01-10 01:32:29 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-31 09:33:35 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
2001-01-10 01:32:29 +00:00
|
|
|
|
2001-01-19 01:12:10 +00:00
|
|
|
#ifndef _nsNSSComponent_h_
|
|
|
|
#define _nsNSSComponent_h_
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 04:29:02 +00:00
|
|
|
#include "mozilla/Mutex.h"
|
2012-10-17 20:48:36 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
2001-02-06 20:09:27 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2001-01-25 01:14:23 +00:00
|
|
|
#include "nsIEntropyCollector.h"
|
2001-02-06 20:09:27 +00:00
|
|
|
#include "nsIStringBundle.h"
|
2001-10-19 22:48:01 +00:00
|
|
|
#include "nsIObserver.h"
|
2001-03-13 21:50:23 +00:00
|
|
|
#include "nsIObserverService.h"
|
2007-02-17 03:47:59 +00:00
|
|
|
#include "nsINSSErrorsService.h"
|
2006-04-04 13:14:40 +00:00
|
|
|
#include "nsNSSCallbacks.h"
|
2014-01-19 22:05:40 +00:00
|
|
|
#include "SharedCertVerifier.h"
|
2001-02-10 02:53:10 +00:00
|
|
|
#include "nsNSSHelper.h"
|
2009-05-20 22:21:51 +00:00
|
|
|
#include "nsClientAuthRemember.h"
|
2013-06-03 06:37:47 +00:00
|
|
|
#include "prerror.h"
|
2014-12-09 12:48:29 +00:00
|
|
|
#include "sslt.h"
|
2013-06-03 06:37:47 +00:00
|
|
|
|
2013-08-19 10:15:55 +00:00
|
|
|
class nsIDOMWindow;
|
2013-06-03 06:37:47 +00:00
|
|
|
class nsIPrompt;
|
|
|
|
class SmartCardThreadList;
|
2013-04-18 00:17:10 +00:00
|
|
|
|
2012-10-27 07:11:35 +00:00
|
|
|
namespace mozilla { namespace psm {
|
|
|
|
|
2014-01-19 22:05:40 +00:00
|
|
|
MOZ_WARN_UNUSED_RESULT
|
|
|
|
::mozilla::TemporaryRef<mozilla::psm::SharedCertVerifier>
|
|
|
|
GetDefaultCertVerifier();
|
2012-10-27 07:11:35 +00:00
|
|
|
|
|
|
|
} } // namespace mozilla::psm
|
|
|
|
|
2001-02-10 02:53:10 +00:00
|
|
|
|
2001-01-10 01:32:29 +00:00
|
|
|
#define NS_NSSCOMPONENT_CID \
|
2014-02-05 00:13:47 +00:00
|
|
|
{0x4cb64dfd, 0xca98, 0x4e24, {0xbe, 0xfd, 0x0d, 0x92, 0x85, 0xa3, 0x3b, 0xcb}}
|
2001-01-10 01:32:29 +00:00
|
|
|
|
2002-09-17 19:09:11 +00:00
|
|
|
#define PSM_COMPONENT_CONTRACTID "@mozilla.org/psm;1"
|
|
|
|
|
2001-02-07 19:00:52 +00:00
|
|
|
//Define an interface that we can use to look up from the
|
|
|
|
//callbacks passed to NSS.
|
|
|
|
|
2014-07-24 19:58:14 +00:00
|
|
|
#define NS_INSSCOMPONENT_IID_STR "e60602a8-97a3-4fe7-b5b7-56bc6ce87ab4"
|
2001-02-07 19:00:52 +00:00
|
|
|
#define NS_INSSCOMPONENT_IID \
|
2014-07-24 19:58:14 +00:00
|
|
|
{ 0xe60602a8, 0x97a3, 0x4fe7, \
|
|
|
|
{ 0xb5, 0xb7, 0x56, 0xbc, 0x6c, 0xe8, 0x7a, 0xb4 } }
|
2001-02-07 19:00:52 +00:00
|
|
|
|
2009-02-28 14:06:40 +00:00
|
|
|
enum EnsureNSSOperator
|
|
|
|
{
|
2010-10-26 11:57:18 +00:00
|
|
|
nssLoadingComponent = 0,
|
2009-02-28 14:06:40 +00:00
|
|
|
nssInitSucceeded = 1,
|
|
|
|
nssInitFailed = 2,
|
|
|
|
nssShutdown = 3,
|
2010-10-26 11:57:18 +00:00
|
|
|
nssEnsure = 100,
|
2015-01-16 19:59:25 +00:00
|
|
|
nssEnsureOnChromeOnly = 101,
|
|
|
|
nssEnsureChromeOrContent = 102,
|
2009-02-28 14:06:40 +00:00
|
|
|
};
|
|
|
|
|
2014-05-16 19:47:00 +00:00
|
|
|
extern bool EnsureNSSInitializedChromeOrContent();
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
extern bool EnsureNSSInitialized(EnsureNSSOperator op);
|
2009-02-28 14:06:40 +00:00
|
|
|
|
2011-05-05 20:41:40 +00:00
|
|
|
class nsNSSComponent;
|
|
|
|
|
2001-02-07 19:00:52 +00:00
|
|
|
class NS_NO_VTABLE nsINSSComponent : public nsISupports {
|
|
|
|
public:
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INSSCOMPONENT_IID)
|
2001-02-07 19:00:52 +00:00
|
|
|
|
2014-01-22 01:30:44 +00:00
|
|
|
NS_IMETHOD ShowAlertFromStringBundle(const char* messageID) = 0;
|
2011-11-03 04:02:48 +00:00
|
|
|
|
2014-01-22 01:30:44 +00:00
|
|
|
NS_IMETHOD GetPIPNSSBundleString(const char* name,
|
|
|
|
nsAString& outString) = 0;
|
|
|
|
NS_IMETHOD PIPBundleFormatStringFromName(const char* name,
|
|
|
|
const char16_t** params,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t numParams,
|
2014-01-22 01:30:44 +00:00
|
|
|
nsAString& outString) = 0;
|
2001-02-07 19:00:52 +00:00
|
|
|
|
2014-01-22 01:30:44 +00:00
|
|
|
NS_IMETHOD GetNSSBundleString(const char* name,
|
|
|
|
nsAString& outString) = 0;
|
|
|
|
NS_IMETHOD NSSBundleFormatStringFromName(const char* name,
|
|
|
|
const char16_t** params,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t numParams,
|
2014-01-22 01:30:44 +00:00
|
|
|
nsAString& outString) = 0;
|
2007-06-27 13:12:03 +00:00
|
|
|
|
2003-01-18 14:03:00 +00:00
|
|
|
NS_IMETHOD LogoutAuthenticatedPK11() = 0;
|
2005-06-02 01:17:35 +00:00
|
|
|
|
2014-08-14 16:38:42 +00:00
|
|
|
#ifndef MOZ_NO_SMART_CARDS
|
2014-01-22 01:30:44 +00:00
|
|
|
NS_IMETHOD LaunchSmartCardThread(SECMODModule* module) = 0;
|
2005-06-02 01:17:35 +00:00
|
|
|
|
2014-01-22 01:30:44 +00:00
|
|
|
NS_IMETHOD ShutdownSmartCardThread(SECMODModule* module) = 0;
|
2013-02-17 04:43:16 +00:00
|
|
|
#endif
|
2009-06-24 16:56:52 +00:00
|
|
|
|
2014-01-22 01:30:44 +00:00
|
|
|
NS_IMETHOD IsNSSInitialized(bool* initialized) = 0;
|
2012-10-27 07:11:35 +00:00
|
|
|
|
2014-01-19 22:05:40 +00:00
|
|
|
virtual ::mozilla::TemporaryRef<mozilla::psm::SharedCertVerifier>
|
|
|
|
GetDefaultCertVerifier() = 0;
|
2001-02-07 19:00:52 +00:00
|
|
|
};
|
|
|
|
|
2005-11-11 14:36:26 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsINSSComponent, NS_INSSCOMPONENT_IID)
|
|
|
|
|
2003-01-18 14:03:00 +00:00
|
|
|
class nsNSSShutDownList;
|
2006-04-04 13:14:40 +00:00
|
|
|
class nsCertVerificationThread;
|
2001-02-07 19:00:52 +00:00
|
|
|
|
2001-01-10 01:32:29 +00:00
|
|
|
// Implementation of the PSM component interface.
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsNSSComponent final : public nsIEntropyCollector,
|
2014-08-05 17:33:55 +00:00
|
|
|
public nsINSSComponent,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsSupportsWeakReference
|
2001-01-10 01:32:29 +00:00
|
|
|
{
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 04:29:02 +00:00
|
|
|
typedef mozilla::Mutex Mutex;
|
|
|
|
|
2001-01-10 01:32:29 +00:00
|
|
|
public:
|
2007-04-23 14:21:53 +00:00
|
|
|
NS_DEFINE_STATIC_CID_ACCESSOR( NS_NSSCOMPONENT_CID )
|
2001-01-25 01:14:23 +00:00
|
|
|
|
2001-01-10 01:32:29 +00:00
|
|
|
nsNSSComponent();
|
2001-01-19 01:12:10 +00:00
|
|
|
|
2013-07-19 02:24:14 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-01-25 01:14:23 +00:00
|
|
|
NS_DECL_NSIENTROPYCOLLECTOR
|
2001-03-13 21:50:23 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2001-01-19 01:12:10 +00:00
|
|
|
|
|
|
|
NS_METHOD Init();
|
2001-02-06 20:09:27 +00:00
|
|
|
|
2014-01-22 01:30:44 +00:00
|
|
|
static nsresult GetNewPrompter(nsIPrompt** result);
|
|
|
|
static nsresult ShowAlertWithConstructedString(const nsString& message);
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD ShowAlertFromStringBundle(const char* messageID) override;
|
2011-11-03 04:02:48 +00:00
|
|
|
|
2014-01-22 01:30:44 +00:00
|
|
|
NS_IMETHOD GetPIPNSSBundleString(const char* name,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsAString& outString) override;
|
2014-01-22 01:30:44 +00:00
|
|
|
NS_IMETHOD PIPBundleFormatStringFromName(const char* name,
|
|
|
|
const char16_t** params,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t numParams,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsAString& outString) override;
|
|
|
|
NS_IMETHOD GetNSSBundleString(const char* name, nsAString& outString) override;
|
2014-01-22 01:30:44 +00:00
|
|
|
NS_IMETHOD NSSBundleFormatStringFromName(const char* name,
|
|
|
|
const char16_t** params,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t numParams,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsAString& outString) override;
|
|
|
|
NS_IMETHOD LogoutAuthenticatedPK11() override;
|
2002-09-07 05:38:16 +00:00
|
|
|
|
2014-08-14 16:38:42 +00:00
|
|
|
#ifndef MOZ_NO_SMART_CARDS
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD LaunchSmartCardThread(SECMODModule* module) override;
|
|
|
|
NS_IMETHOD ShutdownSmartCardThread(SECMODModule* module) override;
|
2013-02-17 04:43:16 +00:00
|
|
|
void LaunchSmartCardThreads();
|
|
|
|
void ShutdownSmartCardThreads();
|
2014-01-22 01:30:44 +00:00
|
|
|
nsresult DispatchEventToWindow(nsIDOMWindow* domWin,
|
|
|
|
const nsAString& eventType,
|
|
|
|
const nsAString& token);
|
2013-02-17 04:43:16 +00:00
|
|
|
#endif
|
2013-04-18 00:17:10 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD IsNSSInitialized(bool* initialized) override;
|
2005-06-02 01:17:35 +00:00
|
|
|
|
2014-01-19 22:05:40 +00:00
|
|
|
::mozilla::TemporaryRef<mozilla::psm::SharedCertVerifier>
|
2015-03-21 16:28:04 +00:00
|
|
|
GetDefaultCertVerifier() override;
|
2001-02-06 20:09:27 +00:00
|
|
|
|
2014-10-21 16:11:29 +00:00
|
|
|
// The following two methods are thread-safe.
|
|
|
|
static bool AreAnyWeakCiphersEnabled();
|
|
|
|
static void UseWeakCiphersOnSocket(PRFileDesc* fd);
|
|
|
|
|
2014-12-09 12:48:29 +00:00
|
|
|
static void FillTLSVersionRange(SSLVersionRange& rangeOut,
|
|
|
|
uint32_t minFromPrefs,
|
|
|
|
uint32_t maxFromPrefs,
|
|
|
|
SSLVersionRange defaults);
|
|
|
|
|
2014-06-23 22:40:03 +00:00
|
|
|
protected:
|
|
|
|
virtual ~nsNSSComponent();
|
|
|
|
|
2014-01-19 22:05:40 +00:00
|
|
|
private:
|
2013-12-06 08:12:08 +00:00
|
|
|
nsresult InitializeNSS();
|
2012-12-13 17:20:00 +00:00
|
|
|
void ShutdownNSS();
|
2003-02-20 00:19:45 +00:00
|
|
|
|
2014-01-21 06:10:33 +00:00
|
|
|
void LoadLoadableRoots();
|
2006-12-06 15:42:39 +00:00
|
|
|
void UnloadLoadableRoots();
|
2014-01-21 06:10:33 +00:00
|
|
|
void setValidationOptions(bool isInitialSetting,
|
|
|
|
const mozilla::MutexAutoLock& lock);
|
2013-09-13 13:02:15 +00:00
|
|
|
nsresult setEnabledTLSVersions();
|
2001-02-06 20:09:27 +00:00
|
|
|
nsresult InitializePIPNSSBundle();
|
2001-02-14 22:15:53 +00:00
|
|
|
nsresult ConfigureInternalPKCS11Token();
|
2001-11-29 23:36:34 +00:00
|
|
|
nsresult RegisterObservers();
|
2009-02-28 14:06:40 +00:00
|
|
|
nsresult DeregisterObservers();
|
2007-05-14 21:09:58 +00:00
|
|
|
|
|
|
|
// Methods that we use to handle the profile change notifications (and to
|
|
|
|
// synthesize a full profile change when we're just doing a profile startup):
|
|
|
|
void DoProfileChangeNetTeardown();
|
|
|
|
void DoProfileChangeTeardown(nsISupports* aSubject);
|
|
|
|
void DoProfileBeforeChange(nsISupports* aSubject);
|
|
|
|
void DoProfileChangeNetRestore();
|
2014-01-22 01:30:44 +00:00
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 04:29:02 +00:00
|
|
|
Mutex mutex;
|
2014-01-22 01:30:44 +00:00
|
|
|
|
2001-02-06 20:09:27 +00:00
|
|
|
nsCOMPtr<nsIStringBundle> mPIPNSSBundle;
|
2007-06-27 13:12:03 +00:00
|
|
|
nsCOMPtr<nsIStringBundle> mNSSErrorsBundle;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mNSSInitialized;
|
|
|
|
bool mObserversRegistered;
|
2001-11-29 23:36:34 +00:00
|
|
|
static int mInstanceCount;
|
2014-01-22 01:30:44 +00:00
|
|
|
nsNSSShutDownList* mShutdownObjectList;
|
2014-08-14 16:38:42 +00:00
|
|
|
#ifndef MOZ_NO_SMART_CARDS
|
2014-01-22 01:30:44 +00:00
|
|
|
SmartCardThreadList* mThreadList;
|
2013-02-17 04:43:16 +00:00
|
|
|
#endif
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsNetworkDown;
|
2009-04-07 01:51:32 +00:00
|
|
|
|
|
|
|
void deleteBackgroundThreads();
|
|
|
|
void createBackgroundThreads();
|
2014-01-22 01:30:44 +00:00
|
|
|
nsCertVerificationThread* mCertVerificationThread;
|
2009-04-07 01:51:32 +00:00
|
|
|
|
2006-04-04 13:14:40 +00:00
|
|
|
nsNSSHttpInterface mHttpForNSS;
|
2014-01-19 22:05:40 +00:00
|
|
|
mozilla::RefPtr<mozilla::psm::SharedCertVerifier> mDefaultCertVerifier;
|
2013-04-18 00:17:10 +00:00
|
|
|
|
2012-10-27 07:11:35 +00:00
|
|
|
static PRStatus IdentityInfoInit(void);
|
2001-01-10 01:32:29 +00:00
|
|
|
};
|
2001-01-19 01:12:10 +00:00
|
|
|
|
2007-02-17 03:47:59 +00:00
|
|
|
class nsNSSErrors
|
|
|
|
{
|
|
|
|
public:
|
2014-01-22 01:30:44 +00:00
|
|
|
static const char* getDefaultErrorStringName(PRErrorCode err);
|
|
|
|
static const char* getOverrideErrorStringName(PRErrorCode aErrorCode);
|
2012-04-26 23:47:19 +00:00
|
|
|
static nsresult getErrorMessageFromCode(PRErrorCode err,
|
2014-01-22 01:30:44 +00:00
|
|
|
nsINSSComponent* component,
|
|
|
|
nsString& returnedMessage);
|
2007-02-17 03:47:59 +00:00
|
|
|
};
|
|
|
|
|
2010-11-09 16:10:40 +00:00
|
|
|
class nsPSMInitPanic
|
|
|
|
{
|
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool isPanic;
|
2010-11-09 16:10:40 +00:00
|
|
|
public:
|
2011-10-17 14:59:28 +00:00
|
|
|
static void SetPanic() {isPanic = true;}
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool GetPanic() {return isPanic;}
|
2010-11-09 16:10:40 +00:00
|
|
|
};
|
|
|
|
|
2001-01-19 01:12:10 +00:00
|
|
|
#endif // _nsNSSComponent_h_
|