2019-6-26 Stone
PHP
<?php
$domain = "ixex.io";
$g = stream_context_create(array('ssl' => array("capture_peer_cert_chain" => true)));
$r = stream_socket_client("ssl://$domain:443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $g);
$cont = stream_context_get_params($r);
foreach($cont["options"]["ssl"]["peer_certificate_chain"] as $key => $val){
//使用openssl扩展解析证书
$cerInfo = openssl_x509_parse($val);
if(strpos($cerInfo['name'], $domain)){
echo "start:".date('Y-m-d', $cerInfo['validFrom_time_t'])."<br>";
echo "end:".date('Y-m-d', $cerInfo['validTo_time_t']);
}
}
标签: php SSL证书
评论(0)
浏览(908)