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
Share on other sites

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

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.