coffee_cn
function get_cert_info($domain){
    $context = stream_context_create([\'ssl\' => [
        \'capture_peer_cert\' => true,
        \'capture_peer_cert_chain\' => true,
        ],
    ]);

    $client = stream_socket_client("ssl://".$domain.":443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
    if($client==false) {
        return false;
    }
    $params = stream_context_get_params($client);
    $cert = $params[\'options\'][\'ssl\'][\'peer_certificate\'];
    $cert_info = openssl_x509_parse($cert);
    return $cert_info;
}
$domain = \'www.baidu.com\';
$cert_info = get_cert_info($domain);
$validTo_time_t = $cert_info[\'validTo_time_t\'];
$validTo_time_d = date(\'Y-m-d H:i:s\', $validTo_time_t);
echo($validTo_time_d);

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2022-02-13
猜你喜欢
  • 2021-12-23
  • 2022-02-10
  • 2021-12-25
  • 2022-12-23
  • 2021-09-03
  • 2021-10-21
  • 2021-05-01
相关资源
相似解决方案