Skip to content

Instantly share code, notes, and snippets.

@saghul
Created March 22, 2011 10:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save saghul/881034 to your computer and use it in GitHub Desktop.
Connect to MediaProxy dispatcher and get sessions using TLS
<?php
$host ='1.2.3.4';
$port = 25061;
$timeout = 10;
$cert = '/tmp/mediaproxy.pem';
$context = stream_context_create(array('ssl'=>array('local_cert'=> $cert,)));
$fp = stream_socket_client('tcp://'.$host.':'.$port, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
if (!$fp) {
echo "ERROR: $errno - $errstr\n";
} else {
if (stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT)) {
fputs($fp, "sessions\r\n");
echo fread($fp,8192);
fclose($fp);
} else {
echo "ERROR: could not enable crypto\n";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment