Step 4: Enable Access Authentication

If you want to secure your Streaming PlayURL: rtmp://, you may the use Access Authentication function, which will give your Streaming PlayURL an expiry time, anyone who tries to play the Live Streaming PlayURL after expiry time will fail.

  1. Under the Streaming Domains page, click the Streaming Domain you want to use the Access Authentication function.

  2. Upon clicking the Enable Access Authentication button, you will see the Access Authentication Key. Please keep the Key secure as you can generate a Streaming PlayURL with authentication using this key.

  3. You can use Generate Play URL to generate a Streaming PlayURL for demo or use the signature algorithm to generate it by yourself.

    Live Stream URL: rtmp://
    Expire Time: 120 (Minutes)
  4. Get the Streaming PlayURL with authentication in the pop-up notice:

Signed URL Generation Steps

  1. Extract pure URL from play URL, e.g. rtmp://
  2. Populate the expiry UTC timestamp and key parameter

     expire_in_seconds = 120000
     timestamp=utc_timestamp_now + expire_in_seconds
     url = extrac_url + '?ts=' + timestamp + '&key=' + auth_key
  3. Use M5 and hex to to sign the URL in order to generate signed string

     signed_str = md5_hex(url)
     e.g. 9c3a348a847dcfd0484839ca536fe9ad
  4. Populate signed str to URL as output URL

     url = extrac_url + '?ts=' + timestamp + '&sign=' + signed_str
     e.g. rtmp://

Python Example Code

import calendar
import datetime
import hashlib

def md5_hex(url):
    m2 = hashlib.md5()
    return m2.hexdigest()

def generate_signed_url(origin_url, expired_in_seconds, auth_key):
    timestamp_now = calendar.timegm(datetime.datetime.utcnow().utctimetuple())
    timestamp = timestamp_now + expired_in_seconds

    temp_signed_url = '%s?ts=%s&key=%s' % (origin_url, timestamp, auth_key)
    temp_signed_url = temp_signed_url[(temp_signed_url.find('://') + 3):]
    signed_str = md5_hex(temp_signed_url)

    return '%s?ts=%s&sign=%s' % (origin_url, timestamp, signed_str)

o_url = 'rtmp://'
expired_in = 120000  \# seconds
authentication_key = 'ABCD'
output_signed_url = generate_signed_url(o_url, expired_in, authentication_key)

© 2018 Conversant Solutions Pte Ltd. All rights reserved.            Updated 2021-12-09 06:49:11

results matching ""

    No results matching ""