IsmAvatar Posted September 8, 2007 Share Posted September 8, 2007 I've been looking for a function or a couple of functions which will allow me to get the Certificate Expiration date for a given website. I've tried openSSL, but their functions only seem to work on the current server, which is useless to me because my server doesn't allow SSL or certificates. I just want the certificate of an external website, e.g. www.gna.org has a certificate (signed by themselves, but a certificate nonetheless). I've also tried cURL, since that allows you to access a remote server, but that will just check their certificate - it doesn't offer any functionality for e.g. checking when it will expire. This seems like a simple enough question, but I haven't found anything about it anywhere, so I'm asking here. Thanks a bunch in advance, -IsmAvatar Quote Link to comment Share on other sites More sharing options...
IsmAvatar Posted September 11, 2007 Author Share Posted September 11, 2007 Bump This seems like a simple enough thing, I can't imagine why it's not getting any responses. Let me restate it in simple terms: I want to check the Certificate, like the SSL certificate, of some website. I want to know the Certificate's Expirtaion Date - when it will expire. But most importantly, this can't just be *my* server, it must be a "remove" server, that is, one that is outside of the scope of the server that is running the php script. Like if I run my script on Google (just an example), but I want to get the Certificate of Sun's webpage, so that I can see when it will expire. Quote Link to comment Share on other sites More sharing options...
damon1977 Posted October 23, 2010 Share Posted October 23, 2010 $host = 'www.example.com'; $context = stream_context_create(array('ssl' => array('capture_peer_cert' => TRUE))); $html = file_get_contents('https://'.$host, NULL, $context); $opts = stream_context_get_options($context); $ssl = openssl_x509_parse($opts['ssl']['peer_certificate']); $expdate = DateTime::createFromFormat('ymd', substr($ssl['validTo'], 0, 6)); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.