diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index f3ee8137..df7b6033 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -2092,7 +2092,7 @@ class X509 * * If $date isn't defined it is assumed to be the current date. * - * @param int $date optional + * @param \DateTime|string $date optional * @access public */ function validateDate($date = null) @@ -2102,7 +2102,7 @@ class X509 } if (!isset($date)) { - $date = new DateTime($date, new DateTimeZone(@date_default_timezone_get())); + $date = new DateTime(null, new DateTimeZone(@date_default_timezone_get())); } $notBefore = $this->currentCert['tbsCertificate']['validity']['notBefore']; @@ -2111,6 +2111,14 @@ 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())); + } + switch (true) { case $date < new DateTime($notBefore, new DateTimeZone(@date_default_timezone_get())): case $date > new DateTime($notAfter, new DateTimeZone(@date_default_timezone_get())):