From 476cb127b16e0759066b5e69c52f2aa42117bfbe Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 22 Nov 2018 13:28:42 -0600 Subject: [PATCH] X509: fix errors with validateDate --- phpseclib/File/X509.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index df7b6033..2a150ce7 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -2111,17 +2111,16 @@ class X509 $notAfter = $this->currentCert['tbsCertificate']['validity']['notAfter']; $notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime']; - switch (true) { - case is_string($date): - $date = new DateTime($date, new DateTimeZone(@date_default_timezone_get())); - default: - $notBefore = new DateTime($notBefore, new DateTimeZone(@date_default_timezone_get())); - $notAfter = new DateTime($notAfter, new DateTimeZone(@date_default_timezone_get())); + if (is_string($date)) { + $date = new DateTime($date, new DateTimeZone(@date_default_timezone_get())); } + $notBefore = new DateTime($notBefore, new DateTimeZone(@date_default_timezone_get())); + $notAfter = new DateTime($notAfter, new DateTimeZone(@date_default_timezone_get())); + switch (true) { - case $date < new DateTime($notBefore, new DateTimeZone(@date_default_timezone_get())): - case $date > new DateTime($notAfter, new DateTimeZone(@date_default_timezone_get())): + case $date < $notBefore: + case $date > $notAfter: return false; }