作者 刘锟

update

... ... @@ -310,6 +310,8 @@ class DomainInfo extends Command
*/
public function updateDomainSsl($domain)
{
$valid_from = '';
$valid_to = '';
try {
$context = stream_context_create([
'ssl' => [
... ... @@ -320,15 +322,13 @@ class DomainInfo extends Command
],
]);
$stream = stream_socket_client('ssl://' . $domain . ':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if (!$stream) {
die("Failed to connect: $errno - $errstr");
}
if($stream){
$remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
if (!$remote_cert) {
die("Failed to retrieve certificate");
}
if($remote_cert){
$valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
$valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
}
}
fclose($stream);
} catch (\Exception $e) {
$valid_from = '';
... ...