note 77496 added to function.stream-socket-client
| From: | wbeaver at afilais dot info | Date: | Fri, 31 Aug 2007 21:05:59 +0000 |
| Subject: | note 77496 added to function.stream-socket-client | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129948@lists.php.net to get a copy of this message | ||
# 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";
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 66.114.90.6
----
Manual Page -- http://www.php.net/manual/en/function.stream-socket-client.php
Edit -- https://master.php.net/note/edit/77496
Del: integrated -- https://master.php.net/note/delete/77496/integrated
Del: useless -- https://master.php.net/note/delete/77496/useless
Del: bad code -- https://master.php.net/note/delete/77496/bad+code
Del: spam -- https://master.php.net/note/delete/77496/spam
Del: non-english -- https://master.php.net/note/delete/77496/non-english
Del: in docs -- https://master.php.net/note/delete/77496/in+docs
Del: other reasons-- https://master.php.net/note/delete/77496
Reject -- https://master.php.net/note/reject/77496
Search -- https://master.php.net/manage/user-notes.php