Created
March 22, 2011 10:32
-
-
Save saghul/881034 to your computer and use it in GitHub Desktop.
Connect to MediaProxy dispatcher and get sessions using TLS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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