Skip to content

A Simple Key Server

Here is an example of a simple key server for AES-128 or SAMPLE-AES encryption:

cas-server.php:

<?php
  header("HTTP/1.0 200 OK");
  $resource = $_GET["file"];
  $number = $_GET["number"];
  error_log("Server is requesting key ".$number." for ".$resource." from ".$_SERVER["REMOTE_ADDR"]);
  header("X-Key-Url: http://".$_SERVER["HTTP_HOST"]."/user-key.php?name=".$resource."&number=".$number);

  $input = $resource.".".$number;
  $key = hash('md4',$input);
  header("Content-Length: ".strlen($key));
  echo $key;
?>

user-key.php:

<?php
  header("HTTP/1.0 200 OK");
  $resource = $_GET["name"];
  $number = $_GET["number"];

  $input = $resource.".".$number;
  $key = hex2bin(hash('md4',$input));
  header("Content-Length: ".strlen($key));
  header("Content-Type: application/octet-stream");
  error_log("User is requesting key ".$number." for ".$resource." from ".$_SERVER["REMOTE_ADDR"]);
  echo $key;
?>

Place these files into a web server directory. cas-server.php must be accessible for Flussonic, user-key.php must be accessible for clients.

Configure DRM for stream in the following way:

stream tvchannel {
  input udp://239.0.0.1:1234;
  protocols dash hls;
  drm aes128 keyserver=http://192.168.0.80:4500/cas-server.php;
}

where http://192.168.0.80:4500/cas-server.php is an url of PHP script above.

Find the latest list of settings for a simple key server for AES-128 or SAMPLE-AES encryption in the Flussonic API reference by selecting aes128 or sample_aes correspondingly in the drop-down list of vendors.

Flussonic will rotate keys once per 10 minutes.