Hello,
I want to use the SecureToken version 2 to protect my live and vod streams
i did search the froum and found the php code in these topics
http://community.wowza.com/t/-/47255
http://community.wowza.com/t/-/46955
unfortunately it doesn’t work for me and i can not play the sample.mp4 test stream
I has updated my wowza installation to latest version 4.6 and want to use the wowza internal hash protection instead of wmspanel.
is there anything missed in my configuration ?
Thank you in advance.
here is the configuration:
Wowza server: 192.168.1.1
SecureToken: Protect all protocols using hash (SecureToken version 2)
Shared Secret: abcde
Include client IP address in hash generation : Enabled
Hash Query Parameter Prefix : wowzatoken
Webserver : 192.168.1.2
client load the JW player : 192.168.1.2
Time & date : the same in Wowza , Webserver and client
<?php
$clientIP = 192.168.1.2; // i did set null for disabled Client ip address test.
$host = "192.168.1.1"; // your ip/host
$url= "rtmp://".$host.":1935/";
$stream = "vod/_definst_/mp4:sample.mp4"; // your stream
$start = time();
$end = strtotime("+30 minutes");
$secret = "abcde";
$tokenName = "wowzatoken";
$hash = "";
if(is_null($clientIP)){
$hash = hash('sha384', $stream."?".$secret."&{$tokenName}endtime=".$end."&{$tokenName}starttime=".$start, true); // generate the hash string
}
else{
$hash = hash('sha384', $stream."?".$clientIP."&".$secret."&{$tokenName}endtime=".$end."&{$tokenName}starttime=".$start, true); // generate the hash string
}
$base64Hash = strtr(base64_encode($hash), '+/', '-_');
// $params = array("{$tokenName}starttime=".$start, "{$tokenName}endtime=".$end, "{$tokenName}hash=".$base64Hash);
$params = array("{$tokenName}starttime=".$start, "{$tokenName}endtime=".$end, "{$tokenName}hash=".$base64Hash);
if(!is_null($clientIP)){
$params[] = $clientIP;
}
sort($params);
$playbackURL = $url.$stream."/playlist.m3u8?";
if(preg_match("/(rtmp)/",$url)){
$playbackURL = $url.$stream."?";
}
foreach($params as $entry){
$playbackURL.= $entry."&";
}
$playbackURL = preg_replace("/(\&)$/","", $playbackURL);
// echo "$playbackURL"; // DEBUG - show fully formed URL
?>
if client ip address be enabled:
rtmp://192.168.1.1:1935/vod/_definst_/mp4:sample.mp4?192.168.1.2&wowzatokenendtime=1482324374&wowzatokenhash=3XoQIHe89wzcNY5KpFJeSbtyxGDi86s1IIJILyzFdoc=&wowzatokenstarttime=1482322574&
if the client ip address be disabled:
rtmp://192.168.1.1:1935/vod/_definst_/mp4:sample.mp4?&wowzatokenendtime=1482349546&wowzatokenhash=0k4pQZBJkUQhmqbeAoT-LKia6DOwVv9eUjspU99wYQmif2N10gbDPqffMa0legeJ&wowzatokenstarttime=1482347746