#46747 [Bgs]: validFrom_time_t of certificate in Windows is difference with Unix system

From: Date: Fri, 16 Jan 2009 02:18:14 +0000
Subject: #46747 [Bgs]: validFrom_time_t of certificate in Windows is difference with Unix system
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-132932@lists.php.net to get a copy of this message
ID: 46747 User updated by: hunreal at gmail dot com Reported By: hunreal at gmail dot com Status: Bogus Bug Type: OpenSSL related Operating System: Windows, FreeBSD PHP Version: 5.2.6 New Comment: Tried set date_default_timezone_set('Asia/Shanghai'); but the problem is still exists. OS: Windows Vista Previous Comments: ------------------------------------------------------------------------ [2008-12-08 11:41:46] jani@php.net One of those machines has wrong timezone set. Use the date_default_timezone_set() function in your script to set the correct one in both. And check those machines' system time too. This is not a PHP bug. ------------------------------------------------------------------------ [2008-12-04 06:27:20] hunreal at gmail dot com Description: ------------ I used openssl_x509_parse() to get certificate infomation. But the values, 'validFrom_time_t' and 'validTo_time_t' in Windows is difference with Unix system. It's same php code, same certificate file. But two result is not the same. By used openssl CLI, I am sure that is Windows PHP issue. Reproduce code: --------------- PHP code: <?php $crtinfo = openssl_x509_parse(file_get_contents("my.cer")); echo $crtinfo['validFrom']," ",$crtinfo['validFrom_time_t'],"\n"; echo $crtinfo['validTo']," ",$crtinfo['validTo_time_t'],"\n"; echo date("Y-m-d H:i:s", $crtinfo['validFrom_time_t']),"\n"; echo date("Y-m-d H:i:s", $crtinfo['validTo_time_t']),"\n"; ?> Openssl CLI: openssl x509 -dates -noout -in my.cer You can use any certificate. Expected result: ---------------- In windows, PHP code output, 070126220002Z 1169845202 090126033531Z 1232937331 2007-01-27 05:00:02 2009-01-26 10:35:31 ------------------------------ In Unix, PHP code output, 070126220002Z 1169848802 090126033531Z 1232940931 2007-01-27 06:00:02 2009-01-26 11:35:31 ------------------------------ BTW, my timezone is set to Asia/Shanghai, GMT+8 Actual result: -------------- OpenSSL CLI output, notBefore=Jan 26 22:00:02 2007 GMT notAfter=Jan 26 03:35:31 2009 GMT ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46747&edit=1

« previous php.bugs (#132932) next »