Help Center/ Live/ Best Practices/ Protecting Live Resources
Updated on 2024-09-27 GMT+08:00

Protecting Live Resources

Scenario Description

To protect your live resources from unauthorized download or theft, you can configure referer validation, URL validation or an access control list (ACL), or disable stream pushing.

  • After the authentication mechanism is enabled, CDN identifies and filters visitors. Only those who meet the rules can use Live. Other illegitimate requests will be rejected.
  • If live content is non-compliant or has been used by unauthorized users, you can disable the stream.

Implementation

As shown in Figure 1, Live provides the following functions to protect live resources.

Figure 1 Security architecture
  • Stream Authentication
    • URL validation: The streamer requests pushing streams via the ingest URL with the encrypted string carried. CDN verifies the request based on authentication information carried in the ingest URL. Only requests that pass the verification are allowed.
    • Access control lists (ACLs): CDN allows or rejects stream pushing requests based on the blocklist or trustlist you configured.
  • Playback Authentication
    • Referer validation: CDN identifies the referer field in a playback request based on the blocklist or trustlist to reject or allow the playback request.
    • URL validation: The viewer requests playback via the streaming URL with the encrypted string carried. CDN checks whether the streaming URL is valid based on authentication information in the URL. Only requests that pass the verification are allowed.
    • ACLs: CDN rejects or allows playback requests based on the blocklist or trustlist you configured.
  • Disabling a Live Stream: If live content is non-compliant or the ingest URL has been used by unauthorized users, you can add this stream to the ACL on the Live console to disable the stream. The stream cannot be pushed again until you remove it from the ACL.

Stream Authentication

Before pushing a live stream, configure the URL validation or an ACL.

  1. Log in to the Live console.
  2. In the navigation pane, choose Domains.
  3. Click Manage in the Operation column of the desired domain name.
  4. In the navigation pane, choose Basic Settings > Access Control.
  5. Configure authentication as required.

    • URL validation

      If you need to customize other validation rules, submit a service ticket to contact Huawei Cloud technical support.

      1. Click URL Validation. The URL Validation dialog box is displayed.
      2. Toggle on the Status switch to configure related parameters.
        Figure 2 Configuring URL validation
        Table 1 URL validation parameters

        Parameter

        Description

        Type

        You can use signing method A, B, C, or D to calculate a signed string.

        NOTE:

        Signing methods A, B, and C have security risks. Signing method D is more secure and recommended.

        Key

        Authentication key.

        • You can customize a key. A key consists of 32 characters. Only letters and digits are allowed.
        • A key can also be automatically generated.

        Duration

        Timeout interval of URL authentication information, that is, the maximum difference between the request time carried in authentication information and the time when Live receives the request. This parameter is used to check whether an ingest URL or streaming URL expires. The value ranges from 1 minute to 30 days and is expressed in seconds.

      3. Click OK.
      4. Generate a signed ingest URL in either of the following ways.
        After URL validation is configured, the original URL cannot be used. You need to generate a new ingest URL.
        • Automatic generation: Use the signed URL generation tool to quickly generate a signed URL. For details, see Signed URL Generation Tool.
        • Manual combination: Manually generate a signed URL based on the configured authentication type. For details about the combination example, see URL Validation.
          • Signing method A
            Signed URL format:
            Original URL?auth_key={timestamp}-{rand}-{uid}-{md5hash}
            Formula for calculating md5hash is:
            sstring = "{URI}-{Timestamp}-{rand}-{uid}-{Key}"
            HashValue = md5sum(sstring)
          • Signing method B
            Signed URL format:
            Original URL?txSecret=md5(Key + Stream Name + txTime)&txTime=hex(timestamp)
          • Signing method C
            Signed URL format:
            Original URL?auth_info={Encrypted string}.{EncodedIV}

            Algorithms for generating the authentication fields are as follows:

            LiveID = <AppName>+"/"+<StreamName>

            Encrypted string = UrlEncode(Base64(AES128(<Key>,"$"+<Timestamp>+"$"+<LiveID>+"$"+<CheckLevel>)))

            EncodedIV = Hex(IV used for encryption)

          • Signing method D
            Signed URL format:
            Original URL?hwSecret=hmac_sha256(Key, Stream Name + hwTime)&hwTime=hex(timestamp)
      5. Verify whether URL validation has taken effect.

        Use a third-party streaming tool to verify the signed ingest URL. If the original ingest URL does not work but the signed ingest URL works, URL validation has taken effect.

    • IP ACL
      1. Click IP ACL. The IP ACL dialog box is displayed.
      2. Toggle on the Status switch to configure an IP address ACL.
        Figure 3 Configuring an IP address ACL
      3. Select IP address blocklist or IP address trustlist, and enter IP addresses or IP address ranges.
      4. Click OK.

Playback Authentication

You can configure referer validation, URL validation, or an ACL for streaming domain names.

  1. Log in to the Live console.
  2. In the navigation pane, choose Domains.
  3. Click Manage in the Operation column of the desired domain name.
  4. In the navigation pane, choose Basic Settings > Access Control.
  5. Configure authentication as required.

    • Referer validation
      1. Click Referer Validation. The Referer Validation dialog box is displayed.
      2. Toggle on the Status switch to configure related parameters.
        Figure 4 Configuring referer validation
        Table 2 Parameter description

        Parameter

        Description

        Type

        The blacklist and whitelist are supported.
        • Referer blacklist allows all domains access to CDN except for the domains added to the blacklist.
        • Referer whitelist denies all domains access to CDN except for the domains added to the whitelist.

        You can set whether to allow requests with empty referer fields, that is, whether to allow access through the browser address bar.

        Rule

        Domain name in the blacklist or whitelist.

        • You can input 1 to 100 domain names. Use semicolons (;) to separate domain names.
        • Domain names are matched using regular expressions. If ^http://test.*com$ is entered, http://test.example.com and http://test.example01.com are also matched.
      3. Click OK.
    • URL validation

      The method of configuring URL validation for streaming domain names is the same as that for ingest domain names. For details, see Stream Authentication.

    • IP ACL

      The method of configuring an ACL for streaming domain names is the same as that for ingest domain names. For details, see Stream Authentication.

Disabling a Live Stream

If live content is non-compliant or the ingest URL has been used by unauthorized users, you can disable the stream to protect your live content.

  1. Log in to the Live console.
  2. In the navigation pane, choose Streaming > Streams.
  3. Locate the domain name for which stream push is to be disabled.
  4. Click Disable in the Operation column.

    Select the time when stream push is resumed. You can view information about disabled livestreams on the Disabled tab.

    Figure 5 Configuration of disabling stream push

    Limited duration: The livestream cannot be pushed until the time indicated by Resumed arrives. Livestreams can be disabled for up to 90 days.

Once the stream is disabled, the ingest URL cannot be used before the stream is resumed.