Bug 1545743 - Don't use validity.not{After,Before}LocalTime for parsing date information in NetErrorChild.jsm. r=prathiksha
authorJohann Hofmann <jhofmann@mozilla.com>
Mon, 13 May 2019 20:18:07 +0000
changeset 532474 f8d305fa503b24a1a965a6dd02c6ee2a3cdfd258
parent 532473 aca591c75b072b5737b372a4aa226a5aba502b1d
child 532475 e3fc2a2d52de73e82fbf2fe0d4de1afed118d056
push id11268
push usercsabou@mozilla.com
push dateTue, 14 May 2019 15:24:22 +0000
treeherdermozilla-beta@5fb7fcd568d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersprathiksha
bugs1545743
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1545743 - Don't use validity.not{After,Before}LocalTime for parsing date information in NetErrorChild.jsm. r=prathiksha Differential Revision: https://phabricator.services.mozilla.com/D30431
browser/actors/NetErrorChild.jsm
browser/base/content/browser.js
--- a/browser/actors/NetErrorChild.jsm
+++ b/browser/actors/NetErrorChild.jsm
@@ -270,39 +270,29 @@ class NetErrorChild extends ActorChild {
         technicalInfo.textContent = "";
         let brandName = gBrandBundle.GetStringFromName("brandShortName");
         msg = gPipNSSBundle.formatStringFromName("certErrorMismatch3", [brandName, hostString], 2) + " ";
         technicalInfo.append(msg + "\n");
       }
     }
 
     if (input.data.isNotValidAtThisTime) {
-      let nowTime = new Date().getTime() * 1000;
-      let msg = "";
-      let notAfterLocalTime = formatter.format(new Date(input.data.validity.notAfterLocalTime));
-      if (input.data.validity.notBefore) {
-        let notBeforeLocalTime = formatter.format(new Date(input.data.validity.notBeforeLocalTime));
-        if (nowTime > input.data.validity.notAfter) {
-          technicalInfo.textContent = "";
-          msg += gPipNSSBundle.formatStringFromName("certErrorExpiredNow3",
-                                                  [hostString, notAfterLocalTime], 2);
-          msg += "\n";
-        } else {
-          technicalInfo.textContent = "";
-          msg += gPipNSSBundle.formatStringFromName("certErrorNotYetValidNow3",
-                                                    [hostString, notBeforeLocalTime], 2);
-          msg += "\n";
-         }
-        } else {
-          // If something goes wrong, we assume the cert expired.
-          technicalInfo.textContent = "";
-          msg += gPipNSSBundle.formatStringFromName("certErrorExpiredNow3",
-                                                    [hostString, notAfterLocalTime], 2);
-          msg += "\n";
+      let msg;
+      if (input.data.validity.notBefore && (Date.now() < input.data.validity.notAfter)) {
+        let notBeforeLocalTime = formatter.format(new Date(input.data.validity.notBefore));
+        msg = gPipNSSBundle.formatStringFromName("certErrorNotYetValidNow3",
+                                                 [hostString, notBeforeLocalTime], 2);
+      } else {
+        let notAfterLocalTime = formatter.format(new Date(input.data.validity.notAfter));
+        msg = gPipNSSBundle.formatStringFromName("certErrorExpiredNow3",
+                                                 [hostString, notAfterLocalTime], 2);
       }
+      msg += "\n";
+
+      technicalInfo.textContent = "";
       technicalInfo.append(msg);
     }
     technicalInfo.append("\n");
 
     // Add link to certificate and error message.
     let linkPrefix = gPipNSSBundle.GetStringFromName("certErrorCodePrefix3");
     let detailLink = doc.createElement("a");
     detailLink.append(input.data.codeString);
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3233,20 +3233,18 @@ var BrowserOnClick = {
         goBackFromErrorPage();
         break;
 
       case "advancedButton":
         securityInfo = getSecurityInfo(securityInfoAsString);
         let errorInfo = getDetailedCertErrorInfo(location,
                                                  securityInfo);
         let validityInfo = {
-          notAfter: securityInfo.serverCert.validity.notAfter,
-          notBefore: securityInfo.serverCert.validity.notBefore,
-          notAfterLocalTime: securityInfo.serverCert.validity.notAfterLocalTime,
-          notBeforeLocalTime: securityInfo.serverCert.validity.notBeforeLocalTime,
+          notAfter: securityInfo.serverCert.validity.notAfter / 1000,
+          notBefore: securityInfo.serverCert.validity.notBefore / 1000,
         };
         browser.messageManager.sendAsyncMessage("CertErrorDetails", {
             code: securityInfo.errorCode,
             info: errorInfo,
             codeString: securityInfo.errorCodeString,
             certIsUntrusted: securityInfo.isUntrusted,
             certSubjectAltNames: securityInfo.serverCert.subjectAltNames,
             validity: validityInfo,