Click to See Complete Forum and Search --> : Verifying SSL via curl


Slack006
12-19-2003, 12:13 AM
Hey folks, I'm looking for a bit of guidance here. I'm trying to code a script that will install a larger PHP script. Basically an install script for those not so familiar or comfortable with PHP. I've got it building the SQL database, and verifying bits of the config file. Question is, how would I go about using CURL to verify an SSL link. One of the config entries is the users SSL URL, and I want the installer to verify if it is actually SSL, and certificate verified... The function I've been working on is below. This seems like it should be such a simple thing, but I haven't used curl for anything and this is rather new territory for me in PHP... Any help would be grand.


function checkSSL() {
global $SEC_URL;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $SEC_URL);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt ($ch, CURLOPT_PORT, 443);
$ssl_info = curl_getinfo ($ch, CURLINFO_SSL_VERIFYRESULT);
curl_exec ($ch);
curl_close($ch);
print "<P>Testing $SEC_URL for SSL:<BR>$ssl_info</P>";
}