From 91ad081fb776ade5d4331a9b34e1cc9a3d93f0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Alarc=C3=B3n?= Date: Thu, 7 Mar 2019 14:50:15 +0100 Subject: [PATCH] cert.notBefore & cert.notAfter are undefined At least in my certs (V2) cert.notBefore & cert.notAfter are always undefined. --- src/util/isExpired.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/isExpired.js b/src/util/isExpired.js index e485c62..526f387 100644 --- a/src/util/isExpired.js +++ b/src/util/isExpired.js @@ -5,8 +5,11 @@ const forge = require('node-forge') const diffDays = (certExpiration, now) => Math.round(Math.abs((certExpiration.getTime() - now.getTime()) / (24 * 60 * 60 * 1000))) -const certInValid = (cert, date) => - (cert.notBefore > date > cert.notAfter || diffDays(new Date(cert.validity.notAfter), date) < 30) +const certInValid = (cert, date) => { + const notBefore = cert.notBefore || new Date(cert.validity.notBefore) + const notAfter = cert.notAfter || new Date(cert.validity.notAfter) + return (notBefore > date > notAfter || diffDays(notAfter, date) < 30) +} module.exports = certKey => readFile(