note 77496 deleted from function.stream-socket-client by nlopess

From: Date: Sat, 01 Sep 2007 11:40:49 +0000
Subject: note 77496 deleted from function.stream-socket-client by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-129970@lists.php.net to get a copy of this message
Note Submitter: wbeaver at afilais dot info ---- # Some may find it useful to know that your caCert # must be in pem format, and that PHP seems to like # your key, cert, and cacert pem's to be concatenated # in a single file (I suffered various "unknown chain" # errors, otherwise) # # So, (linux users), concat your components as follows: # (where current working dir is dir where # cert components are stored) # # cat key.pem >certchain.pem # cat cert.pem >>certchain.pem # cat cacert.pem >>certchain.pem # # Then, the php.... ################################## <?php $host = 'host.domain.tld'; $port = 1234; $timeout = 10; $cert = '/path/to/your/certchain/certchain.pem'; $context = stream_context_create(array('ssl'=>array('local_cert'=> $cert, ))); if ($fp = stream_socket_client('ssl://'.$host.':'.$port, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context)) { fwrite($fp, "\n"); echo fread($fp,8192); fclose($fp); } else { echo "ERROR: $errno - $errstr<br />\n"; } ?>

« previous php.notes (#129970) next »