Issue #1053 - Remove android support from nsNSSComponent.cpp

This commit is contained in:
Matt A. Tobin 2020-02-28 16:51:00 -05:00 • committed by Roy Tam
commit 56f64bd775

View file

@ -1267,26 +1267,19 @@ nsNSSComponent::InitializePIPNSSBundle()
nsresult rv; nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv)); nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
#ifdef ANDROID
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
MOZ_RELEASE_ASSERT(bundleService);
#endif
if (NS_FAILED(rv) || !bundleService) if (NS_FAILED(rv) || !bundleService)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
bundleService->CreateBundle("chrome://pipnss/locale/pipnss.properties", bundleService->CreateBundle("chrome://pipnss/locale/pipnss.properties",
getter_AddRefs(mPIPNSSBundle)); getter_AddRefs(mPIPNSSBundle));
#ifdef ANDROID
MOZ_RELEASE_ASSERT(mPIPNSSBundle);
#endif
if (!mPIPNSSBundle) if (!mPIPNSSBundle)
rv = NS_ERROR_FAILURE; rv = NS_ERROR_FAILURE;
bundleService->CreateBundle("chrome://pipnss/locale/nsserrors.properties", bundleService->CreateBundle("chrome://pipnss/locale/nsserrors.properties",
getter_AddRefs(mNSSErrorsBundle)); getter_AddRefs(mNSSErrorsBundle));
#ifdef ANDROID
MOZ_RELEASE_ASSERT(mNSSErrorsBundle);
#endif
if (!mNSSErrorsBundle) if (!mNSSErrorsBundle)
rv = NS_ERROR_FAILURE; rv = NS_ERROR_FAILURE;
@ -1488,9 +1481,7 @@ CipherSuiteChangeObserver::StartObserve()
if (!sObserver) { if (!sObserver) {
RefPtr<CipherSuiteChangeObserver> observer = new CipherSuiteChangeObserver(); RefPtr<CipherSuiteChangeObserver> observer = new CipherSuiteChangeObserver();
nsresult rv = Preferences::AddStrongObserver(observer.get(), "security."); nsresult rv = Preferences::AddStrongObserver(observer.get(), "security.");
#ifdef ANDROID
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
#endif
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
sObserver = nullptr; sObserver = nullptr;
return rv; return rv;
@ -1724,9 +1715,7 @@ GetNSSProfilePath(nsAutoCString& aProfilePath)
#else #else
rv = profileFile->GetNativePath(aProfilePath); rv = profileFile->GetNativePath(aProfilePath);
#endif #endif
#ifdef ANDROID
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
#endif
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
MOZ_LOG(gPIPNSSLog, LogLevel::Error, MOZ_LOG(gPIPNSSLog, LogLevel::Error,
("Could not get native path for profile directory.\n")); ("Could not get native path for profile directory.\n"));
@ -1754,9 +1743,6 @@ nsNSSComponent::InitializeNSS()
MutexAutoLock lock(mutex); MutexAutoLock lock(mutex);
#ifdef ANDROID
MOZ_RELEASE_ASSERT(!mNSSInitialized);
#endif
if (mNSSInitialized) { if (mNSSInitialized) {
// We should never try to initialize NSS more than once in a process. // We should never try to initialize NSS more than once in a process.
MOZ_ASSERT_UNREACHABLE("Trying to initialize NSS twice"); MOZ_ASSERT_UNREACHABLE("Trying to initialize NSS twice");
@ -1775,9 +1761,7 @@ nsNSSComponent::InitializeNSS()
nsAutoCString profileStr; nsAutoCString profileStr;
nsresult rv = GetNSSProfilePath(profileStr); nsresult rv = GetNSSProfilePath(profileStr);
#ifdef ANDROID
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
#endif
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
@ -1791,9 +1775,7 @@ nsNSSComponent::InitializeNSS()
// modules will be loaded). // modules will be loaded).
if (runtime) { if (runtime) {
rv = runtime->GetInSafeMode(&inSafeMode); rv = runtime->GetInSafeMode(&inSafeMode);
#ifdef ANDROID
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
#endif
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -1818,14 +1800,9 @@ nsNSSComponent::InitializeNSS()
// pref has been set to "true", attempt to initialize with no DB. // pref has been set to "true", attempt to initialize with no DB.
if (nocertdb || init_rv != SECSuccess) { if (nocertdb || init_rv != SECSuccess) {
init_rv = NSS_NoDB_Init(nullptr); init_rv = NSS_NoDB_Init(nullptr);
#ifdef ANDROID
MOZ_RELEASE_ASSERT(init_rv == SECSuccess);
#endif
} }
if (init_rv != SECSuccess) { if (init_rv != SECSuccess) {
#ifdef ANDROID
MOZ_RELEASE_ASSERT(false);
#endif
MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("could not initialize NSS - panicking\n")); MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("could not initialize NSS - panicking\n"));
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
} }
@ -1847,9 +1824,7 @@ nsNSSComponent::InitializeNSS()
SSL_OptionSetDefault(SSL_V2_COMPATIBLE_HELLO, false); SSL_OptionSetDefault(SSL_V2_COMPATIBLE_HELLO, false);
rv = setEnabledTLSVersions(); rv = setEnabledTLSVersions();
#ifdef ANDROID
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
#endif
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
@ -1858,9 +1833,7 @@ nsNSSComponent::InitializeNSS()
LoadLoadableRoots(); LoadLoadableRoots();
rv = LoadExtendedValidationInfo(); rv = LoadExtendedValidationInfo();
#ifdef ANDROID
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
#endif
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("failed to load EV info")); MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("failed to load EV info"));
return rv; return rv;
@ -1900,18 +1873,14 @@ nsNSSComponent::InitializeNSS()
ENABLED_0RTT_DATA_DEFAULT)); ENABLED_0RTT_DATA_DEFAULT));
if (NS_FAILED(InitializeCipherSuite())) { if (NS_FAILED(InitializeCipherSuite())) {
#ifdef ANDROID
MOZ_RELEASE_ASSERT(false);
#endif
MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Unable to initialize cipher suite settings\n")); MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Unable to initialize cipher suite settings\n"));
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// ensure the CertBlocklist is initialised // ensure the CertBlocklist is initialised
nsCOMPtr<nsICertBlocklist> certList = do_GetService(NS_CERTBLOCKLIST_CONTRACTID); nsCOMPtr<nsICertBlocklist> certList = do_GetService(NS_CERTBLOCKLIST_CONTRACTID);
#ifdef ANDROID
MOZ_RELEASE_ASSERT(certList);
#endif
if (!certList) { if (!certList) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -1928,9 +1897,7 @@ nsNSSComponent::InitializeNSS()
// Initialize the site security service // Initialize the site security service
nsCOMPtr<nsISiteSecurityService> sssService = nsCOMPtr<nsISiteSecurityService> sssService =
do_GetService(NS_SSSERVICE_CONTRACTID); do_GetService(NS_SSSERVICE_CONTRACTID);
#ifdef ANDROID
MOZ_RELEASE_ASSERT(sssService);
#endif
if (!sssService) { if (!sssService) {
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Cannot initialize site security service\n")); MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Cannot initialize site security service\n"));
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1939,9 +1906,7 @@ nsNSSComponent::InitializeNSS()
// Initialize the cert override service // Initialize the cert override service
nsCOMPtr<nsICertOverrideService> coService = nsCOMPtr<nsICertOverrideService> coService =
do_GetService(NS_CERTOVERRIDE_CONTRACTID); do_GetService(NS_CERTOVERRIDE_CONTRACTID);
#ifdef ANDROID
MOZ_RELEASE_ASSERT(coService);
#endif
if (!coService) { if (!coService) {
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Cannot initialize cert override service\n")); MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Cannot initialize cert override service\n"));
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -2010,9 +1975,7 @@ nsNSSComponent::Init()
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Beginning NSS initialization\n")); MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Beginning NSS initialization\n"));
rv = InitializePIPNSSBundle(); rv = InitializePIPNSSBundle();
#ifdef ANDROID
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
#endif
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Unable to create pipnss bundle.\n")); MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Unable to create pipnss bundle.\n"));
return rv; return rv;
@ -2033,9 +1996,7 @@ nsNSSComponent::Init()
rv = InitializeNSS(); rv = InitializeNSS();
#ifdef ANDROID
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
#endif
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
MOZ_LOG(gPIPNSSLog, LogLevel::Error, MOZ_LOG(gPIPNSSLog, LogLevel::Error,
("nsNSSComponent::InitializeNSS() failed\n")); ("nsNSSComponent::InitializeNSS() failed\n"));
@ -2197,9 +2158,7 @@ nsNSSComponent::RegisterObservers()
nsCOMPtr<nsIObserverService> observerService( nsCOMPtr<nsIObserverService> observerService(
do_GetService("@mozilla.org/observer-service;1")); do_GetService("@mozilla.org/observer-service;1"));
#ifdef ANDROID
MOZ_RELEASE_ASSERT(observerService);
#endif
if (!observerService) { if (!observerService) {
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
("nsNSSComponent: couldn't get observer service\n")); ("nsNSSComponent: couldn't get observer service\n"));
@ -2421,9 +2380,6 @@ InitializeCipherSuite()
NS_ASSERTION(NS_IsMainThread(), "InitializeCipherSuite() can only be accessed in main thread"); NS_ASSERTION(NS_IsMainThread(), "InitializeCipherSuite() can only be accessed in main thread");
if (NSS_SetDomesticPolicy() != SECSuccess) { if (NSS_SetDomesticPolicy() != SECSuccess) {
#ifdef ANDROID
MOZ_RELEASE_ASSERT(false);
#endif
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }