How to get Expiry date from the SSL Certificate file in PHP

前端 未结 3 1139
余生分开走
余生分开走 2021-02-02 00:19

I want to get the expiry date from the SSL Certificate file. There is a web page in PHP that I\'ve created, in which user can upload his SSL Certificate file and I will have to

3条回答
  •  独厮守ぢ
    2021-02-02 01:14

    $certpath = "your_certificate.cer";
    $certinfo = openssl_x509_parse(file_get_contents($certpath));
    if( $certinfo['validFrom_time_t'] > time() || $certinfo['validTo_time_t'] < time() )
        print "Certificate is expired.";
    

提交回复
热议问题