I am using the PHP code below to load the certificate properties of an SSL website:
$dnsname = 'www.google.com';
$dnsport = 443;
$stream = stream_context_create (array("ssl" => array("capture_peer_cert" => true)));
$url = stream_socket_client("ssl://".$dnsname.":".$dnsport, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $stream);
$content = stream_context_get_params($url);
This all works fine when SSL is working OK. But in case no SSL connection can be opened the script results in a PHP warning:
stream_socket_client(): unable to connect to ssl://www.google.nl:443 (Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd. ) in C:\inetpub\monitor\autotask\checkssl.php on line 44
How to prevent the warning? I need a "if" but don't know what to check for.. Please help