Get expiration date of openssl certificate

I analyzed the openssl certificate openssl_x509_parse () and got the array as a result.

Now I need to get the expiration date of this certificate. In the parsed array, I have a validTo_time_t element that contains a valid unix timestamp. But how to determine on which timeline this timestamp belongs?

Thus, I cannot get the real expiration time, because it is a timestamp, because it means different dates in different time zones.

+4
source share
2 answers

php formats this field using its default timezone. you can get it using http://docs.php.net/date_default_timezone_get function

and as soon as you find out the time zone, you can convert it to UTC or whatever you need

+1
source

Unix TimeStamp does not have a time zone. It is defined as the number of seconds since January 1, 1970 in UTC. This is not a definite real date, but only a few seconds. No time zone = no problem.

That is why it is an ideal time indicator for different servers and different regions. You can simply save the unix timestamp, and when you convert it to a date, it will use your timezone to determine the date, it will be automatic, and this means that when converting givin to another timezone, it will be converted to the correct date. Always.

This is true for all timestamps, not just for SSL output. Basic Timestamp Information http://www.unixtimestamp.com/

+2
source

Source: https://habr.com/ru/post/1491926/


All Articles