From 5f251228fe242fdde907e8d82edf330203fa24de Mon Sep 17 00:00:00 2001 From: "AFTECH.RO" <38830718+aftechro@users.noreply.github.com> Date: Sat, 15 Jan 2022 01:20:29 +0000 Subject: [PATCH] Update client_certificate.php - fetch expiry date Future to do: Show issuer - atm, shows country of issue but not the provider, maybe @johnnyq or @wrongecho can have another look here --- client_certificates.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/client_certificates.php b/client_certificates.php index 99615af9d..1e1058a85 100644 --- a/client_certificates.php +++ b/client_certificates.php @@ -100,13 +100,28 @@ $certificate_expire = $row['certificate_expire']; $certificate_updated_at = $row['certificate_updated_at']; $certificate_public_key = $row['certificate_public_key']; + +$url = "https://$certificate_domain"; +$orignal_parse = parse_url($url, PHP_URL_HOST); +$get = stream_context_create(array("ssl" => array("capture_peer_cert" => TRUE))); +$read = stream_socket_client("ssl://".$orignal_parse.":443", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $get); +$cert = stream_context_get_params($read); +$certinfo = openssl_x509_parse($cert['options']['ssl']['peer_certificate']); +// echo "Name: ".$certinfo['name']."
"; +// echo "Subject: ".$certinfo['subject']['C']." ".$certinfo['subject']['ST']." ".$certinfo['subject']['CN']."
"; +// echo "Issuer: ".$certinfo['issuer']['C']." ".$certinfo['subject']['O']." ".$certinfo['subject']['CN']."
"; +// echo "Version: ".$certinfo['version']."
"; +// echo "Valid from: ".gmdate("Y-m-d",$certinfo['validFrom'])." to ".gmdate("Y-m-d",$certinfo['validTo'])."
"; + // $validFrom = date('Y-m-d H:i:s', $data['validFrom_time_t']); + // $validTo = date('Y-m-d H:i:s', $data['validTo_time_t']); ?> + - + - - + + - \ No newline at end of file +