commit 45ffbc50f1f2 Author: David Keeler Date: Fri Oct 13 11:27:30 2017 -0700 Bug 1406396 - Work around NSS utils potentially loading spurious root cert modules. r=mgoodwin, a=ritu, l10n=flod NSS command-line utilities may add a built-in root certificate module with the name "Root Certs" if run on a profile that has a copy of the module file (which is an unexpected configuration in general for Firefox). This can cause breakage. To work around this, PSM now simply deletes any module named "Root Certs" at startup. In an effort to prevent PSM from deleting unrelated modules coincidentally named "Root Certs", we also prevent the user from using the Firefox UI to name modules "Root Certs". MozReview-Commit-ID: ABja3wpShO9 --HG-- extra : histedit_source : 3f8a20980a1f7fbc838b610763369af3ddf95e16 --- security/certverifier/NSSCertDBTrustDomain.cpp | 6 +++++ .../locales/en-US/chrome/pippki/pippki.properties | 5 ++++ .../manager/pki/resources/content/load_device.js | 17 ++++++++++++ .../manager/pki/resources/content/load_device.xul | 4 ++- security/manager/ssl/PKCS11ModuleDB.cpp | 11 ++++++++ .../browser/browser_loadPKCS11Module_ui.js | 30 ++++++++++++++++++++++ .../manager/ssl/tests/unit/test_pkcs11_moduleDB.js | 28 ++++++++++++++++++++ .../manager/ssl/tests/unit/xpcshell-smartcards.ini | 1 + 8 files changed, 101 insertions(+), 1 deletion(-) diff --git security/certverifier/NSSCertDBTrustDomain.cpp security/certverifier/NSSCertDBTrustDomain.cpp index a352d928a3c9..229a0b5df28c 100644 --- security/certverifier/NSSCertDBTrustDomain.cpp +++ security/certverifier/NSSCertDBTrustDomain.cpp @@ -1216,6 +1216,12 @@ LoadLoadableRoots(const nsCString& dir, const nsCString& modNameUTF8) // the return value would be detrimental in that case. int unusedModType; Unused << SECMOD_DeleteModule(modNameUTF8.get(), &unusedModType); + // Some NSS command-line utilities will load a roots module under the name + // "Root Certs" if there happens to be a `DLL_PREFIX "nssckbi" DLL_SUFFIX` + // file in the directory being operated on. In some cases this can cause us to + // fail to load our roots module. In these cases, deleting the "Root Certs" + // module allows us to load the correct one. See bug 1406396. + Unused << SECMOD_DeleteModule("Root Certs", &unusedModType); nsAutoCString fullLibraryPath; if (!dir.IsEmpty()) { diff --git security/manager/locales/en-US/chrome/pippki/pippki.properties security/manager/locales/en-US/chrome/pippki/pippki.properties index 4bf67da7bab2..163384651067 100644 --- security/manager/locales/en-US/chrome/pippki/pippki.properties +++ security/manager/locales/en-US/chrome/pippki/pippki.properties @@ -185,3 +185,8 @@ addExceptionCheckingShort=Checking Information addExceptionCheckingLong2=Attempting to identify this site… addExceptionNoCertShort=No Information Available addExceptionNoCertLong2=Unable to obtain identification status for this site. + +# Load Module Dialog +loadModuleHelp_emptyModuleName=The module name cannot be empty. +# LOCALIZATION NOTE(loadModuleHelp_rootCertsModuleName): Do not translate 'Root Certs' +loadModuleHelp_rootCertsModuleName=‘Root Certs‘ is reserved and cannot be used as the module name. diff --git security/manager/pki/resources/content/load_device.js security/manager/pki/resources/content/load_device.js index b3b020236b93..08831f16e27e 100644 --- security/manager/pki/resources/content/load_device.js +++ security/manager/pki/resources/content/load_device.js @@ -51,3 +51,20 @@ function onDialogAccept() { return true; } + +function validateModuleName() { + let bundle = document.getElementById("pippki_bundle"); + let name = document.getElementById("device_name").value; + let helpText = document.getElementById("helpText"); + helpText.value = ""; + let dialogNode = document.querySelector("dialog"); + dialogNode.removeAttribute("buttondisabledaccept"); + if (name == "") { + helpText.value = bundle.getString("loadModuleHelp_emptyModuleName"); + dialogNode.setAttribute("buttondisabledaccept", true); + } + if (name == "Root Certs") { + helpText.value = bundle.getString("loadModuleHelp_rootCertsModuleName"); + dialogNode.setAttribute("buttondisabledaccept", true); + } +} diff --git security/manager/pki/resources/content/load_device.xul security/manager/pki/resources/content/load_device.xul index b3a82df7ac57..f7cfca3cacf7 100644 --- security/manager/pki/resources/content/load_device.xul +++ security/manager/pki/resources/content/load_device.xul @@ -29,7 +29,8 @@ +