From 136ae6f518be51145f80ef9081467ee6838f0937 Mon Sep 17 00:00:00 2001 From: Sarthak Ahuja <39986642+SarthakAhuja@users.noreply.github.com> Date: Fri, 13 Nov 2026 14:48:44 +0530 Subject: [PATCH] doc: document invalid X509Certificate validity times MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a certificate's notBefore or notAfter time cannot be parsed, validFrom and validTo return the string 'Bad time value', and validFromDate and validToDate return an invalid Date. Relational comparisons with an invalid Date are always false, so a naive expiry check can treat such a certificate as valid. Document the current behavior and tell callers to reject invalid dates first. Signed-off-by: Sarthak Ahuja <39986642+SarthakAhuja@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/67406 Refs: https://github.com/nodejs/node/issues/67285 Reviewed-By: Filip Skokan Reviewed-By: Ulises Gascón Reviewed-By: Tim Perry --- doc/api/crypto.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index fad997430d3..54a2cbef52b 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -3517,6 +3517,9 @@ added: v15.6.0 The date/time from which this certificate is valid. +If the certificate's `notBefore` time cannot be parsed, this is the string +`'Bad time value'`. + ### `x509.validFromDate`