Skip to content

Instantly share code, notes, and snippets.

@shiny
Created July 23, 2017 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiny/702d3cf5a1c8bbe1d9b6166359d2c6af to your computer and use it in GitHub Desktop.
Save shiny/702d3cf5a1c8bbe1d9b6166359d2c6af to your computer and use it in GitHub Desktop.
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
Copy link
Author

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