diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 38dd2515..36b5cb76 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -1070,7 +1070,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 * @return boolean */ @@ -1081,7 +1081,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']; @@ -1090,6 +1090,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())):