0

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.

User
  • 135
  • 2
  • 4
  • 13

1 Answers1

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