From 94bea848e4f36629618dbedafd2e61fa916359c9 Mon Sep 17 00:00:00 2001 From: Johann Hofmann Date: Mon, 13 May 2019 20:18:07 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- browser/actors/NetErrorChild.jsm | 34 +++++++++++--------------------- browser/base/content/browser.js | 6 ++---- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/browser/actors/NetErrorChild.jsm b/browser/actors/NetErrorChild.jsm index be13a719695c..b0b9cd80abd0 100644 --- a/browser/actors/NetErrorChild.jsm +++ b/browser/actors/NetErrorChild.jsm @@ -275,29 +275,19 @@ class NetErrorChild extends ActorChild { } 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"); diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index bab760cfac00..5be8cdccc738 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3238,10 +3238,8 @@ var BrowserOnClick = { 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,