Need to get validTo (expiry) date from x509 certificate and validate with current date. Am using openssl_x509_parse($crtdata) to parse the certificate, any thought on how to get the validTo date from the resulting array. Thanks.
Asked
Active
Viewed 2,271 times
1 Answers
1
Why do not you use print_r which will print the array and gives out the indices or key you need?
I think you can try the following
$arr = openssl_x509_parse($crtdata);
/*To get the validTo*/
$validTo = $arr['ValidTo_time_t'];
This is given as an example at PHP manual page of openssl_x509_parse.
I hope this would help you. But you may face issue in future. Consider this program to update if you plan to update PHP version and test it well.

doptimusprime
- 9,115
- 6
- 52
- 90
-
-
1Because documentation says " The structure of the returned data is (deliberately) not yet documented, as it is still subject to change.". – doptimusprime May 19 '13 at 16:35