mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-27 03:42:40 +00:00
Fixed ASN.1 UTCTime parsing
This commit is contained in:
parent
8abc0ee60c
commit
7fd1eefd66
@ -1222,7 +1222,7 @@ class File_ASN1
|
|||||||
http://www.obj-sys.com/asn1tutorial/node14.html */
|
http://www.obj-sys.com/asn1tutorial/node14.html */
|
||||||
|
|
||||||
$pattern = $tag == FILE_ASN1_TYPE_UTC_TIME ?
|
$pattern = $tag == FILE_ASN1_TYPE_UTC_TIME ?
|
||||||
'#(..)(..)(..)(..)(..)(..)(.*)#' :
|
'#^(..)(..)(..)(..)(..)(..)?(.*)$#' :
|
||||||
'#(....)(..)(..)(..)(..)(..).*([Z+-].*)$#';
|
'#(....)(..)(..)(..)(..)(..).*([Z+-].*)$#';
|
||||||
|
|
||||||
preg_match($pattern, $content, $matches);
|
preg_match($pattern, $content, $matches);
|
||||||
@ -1247,7 +1247,7 @@ class File_ASN1
|
|||||||
$timezone = 0;
|
$timezone = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return @$mktime($hour, $minute, $second, $month, $day, $year) + $timezone;
|
return @$mktime((int)$hour, (int)$minute, (int)$second, (int)$month, (int)$day, (int)$year) + $timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -416,4 +416,46 @@ Mj93S
|
|||||||
|
|
||||||
runkit_constant_remove('FILE_X509_IGNORE_TYPE');
|
runkit_constant_remove('FILE_X509_IGNORE_TYPE');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUtcTimeWithoutSeconds()
|
||||||
|
{
|
||||||
|
$test = '-----BEGIN CERTIFICATE-----
|
||||||
|
MIIGFDCCBPygAwIBAgIDKCHVMA0GCSqGSIb3DQEBBQUAMIHcMQswCQYDVQQGEwJVUzEQMA4GA1UE
|
||||||
|
CBMHQXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hu
|
||||||
|
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
F7xAUxmPUnNb2teatMf2Rmj0fs+d
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
';
|
||||||
|
|
||||||
|
$x509 = new File_X509();
|
||||||
|
|
||||||
|
$cert = $x509->loadX509($test);
|
||||||
|
|
||||||
|
$this->assertEquals($cert['tbsCertificate']['validity']['notBefore']['utcTime'], 'Tue, 07 Jan 2014 00:00:00 +0000');
|
||||||
|
$this->assertEquals($cert['tbsCertificate']['validity']['notAfter']['utcTime'], 'Fri, 01 Apr 2016 07:00:00 +0000');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user