Instantly share code, notes, and snippets.

Embed
What would you like to do?
get-ssl-inform.php
<?php
$g = stream_context_create ([
"ssl" => ["capture_peer_cert" => true],
'http' => [
'method' => 'GET',
'user_agent' => 'shouwang.io ssl detector',
'timeout'=>10
]
]);
$r = fopen("https://www.baidu.com/", "rb", false, $g);
$cont = stream_context_get_params($r);
$cert = openssl_x509_parse($cont["options"]["ssl"]["peer_certificate"]);
echo $cert['subject']['CN'], "\n";
echo date('Y-m-d H:i:s', $cert['validFrom_time_t']), "\n";
echo date('Y-m-d H:i:s', $cert['validTo_time_t']), "\n";
echo $cert['issuer']['O'],"\n";
echo $cert['issuer']['CN'],"\n";
@shiny

This comment has been minimized.

Owner

shiny commented Apr 11, 2018

result:

baidu.com
2017-06-29 08:00:00
2018-08-18 07:59:59
Symantec Corporation
Symantec Class 3 Secure Server CA - G4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment