Jump to content

[SOLVED] Can I check SSL somehow with PHP?


phpknight

Recommended Posts

Ever since I got a server for our site, it just opens new issues.  Here is the problem: My SSL Cert somehow got corrupted.  The server is managed, so they fixed it right away once I noticed it, but nobody was able to checkout until it was fixed, and I cannot check the site every hour.

 

Here is what I want to do (but the server people say it is not possible): Is there a way, by chron or otherwise, to run a PHP  that requests a secure page, and if it does not respond, it emails a warning?

It seems that this should be able to be done without too much trouble.  Any ideas?

 

Link to comment
https://forums.phpfreaks.com/topic/57813-solved-can-i-check-ssl-somehow-with-php/
Share on other sites

yes that is possible, however i am not really experienced into cron, however after asking my friend google for some advise, he gave me these results:

 

http://www.unixgeeks.org/security/newbie/unix/cron-1.html

http://www.aota.net/Script_Installation_Tips/cronhelp.php3

 

greetz,

Ignace

I'd try something like this:

 

Create a test page on the server in question, i.e, ping.php

 

this page is responding

 

Then create a script which requests the test page every n minutes via cron

 

<?php

$url = 'https://www.yourdomain.com/ping.php';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$content = curl_exec ($ch);

curl_close ($ch);\

if($content != 'this page is responding')
    sendAlertEmail();

?>

 

Best,

 

Patrick

Patrick,

 

Thanks for your help.  I had to change the $_url to $url.  This code works if I comment out that SSL_VERIFY_HOST line and use a normal URL.  However, as soon as I put https:// and put that line back in, the content comes back as nothing, but it should have a string length of 24 (the line in the code plus the end line). 

 

Any ideas?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.