This topic describes how to configure M3U8 encryption and rewriting.

Overview

To accelerate the delivery of HTTP Live Streaming (HLS) content, Alibaba Cloud Content Delivery Network (CDN) rewrites an #EXT-X-KEY tag in an M3U8 file for HLS content. After the #EXT-X-KEY tag is rewritten, the specified parameter name and value are added to the end of the URI attribute in the tag to decrypt the M3U8 file. Client requests include the parameter name and value that are required for rewriting.

The M3U8 encryption and rewriting feature allows you to enable M3U8 encryption and rewrite M3U8 files for HLS content. You can specify a custom parameter name to rewrite an M3U8 file. The custom parameter name must be the same as that included in the client requests. If you do not use a custom parameter name, the parameter name MtsHlsUriToken is used by default.

Procedure

  1. Log on to the Alibaba Cloud CDN console.
  2. In the left-side navigation pane, click Domain Names.
  3. On the Domain Names page, find the target domain name and click Manage.
  4. In the left-side navigation pane of the specified domain, click Video.
  5. In the M3U8 Encryption and Rewrite section, turn on M3U8 Encryption and Rewrite.
    Turn on M3U8 Encryption and Rewrite
    Note After you turn on M3U8 Encryption and Rewrite, the parameter name MtsHlsUriToken is used by default.
  6. If you want to use a custom parameter name that is the same as that included in the client requests, perform the following steps:
    1. Click Modify next to the Custom Parameter Name field.
    2. In the Custom Parameter Name dialog box, set the Parameter Name parameter.
      Set the parameter name
      Note The parameter names are case-sensitive. Make sure that the specified parameter name is the same as that included in the client requests. For example, if the client requests include the foobar parameter name, the specified custom parameter name FooBar cannot be used to retrieve HLS content.
    3. Click OK to complete the configuration.

Example

Log on to the Alibaba Cloud CDN console, turn on M3U8 Encryption and Rewrite, and then set the custom parameter name to foobar. The following figure shows this custom parameter name.Example 1
A client request includes the foobar parameter. The parameter value is yyyy. To decrypt the M3U8 file and accelerate the delivery of the requested HLS content, Alibaba Cloud CDN adds foobar=yyyy to the end of the URI attribute in the #EXT-X-KEY tag.Example 2