apache openssl_x509_parse / validTo_time_t为我提供了“1970年1月1日”

xeufq47z  于 2023-02-13  发布在  Apache
关注(0)|答案(1)|浏览(95)

为Apache启用OpenSSL 1.1.1 php
所有研究中心给予“1970-01-01”作为失效日期

<?php

$websites = $_POST['websites'];
$websites = explode(',', $websites);

foreach ($websites as $website) :
    $website = trim($website);
    $cert = openssl_x509_parse(file_get_contents("https://{$website}"));
    $expiration = date('Y-m-d', $cert['validTo_time_t']);
    echo "{$website}: {$expiration}<br>";
endforeach;

?>

任何研究中心给出相同的日期

kcrjzv8t

kcrjzv8t1#

将站点的内容(HTML)传递给openssl_x509_parse:

$cert = openssl_x509_parse(file_get_contents("https://{$website}"));

您需要证书对象或实际证书的内容

openssl_x509_parse(OpenSSLCertificate|string $certificate, bool $short_names = true): array|false

https://www.php.net/manual/en/function.openssl-x509-parse.php
有关示例,请参见:How to get SSL certificate info with CURL in PHP?

相关问题