Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClearKey - Error generating key request as kid is not valid base64url encoded. #4011

Closed
sr1990 opened this issue Aug 2, 2022 · 4 comments · Fixed by #4026
Closed

ClearKey - Error generating key request as kid is not valid base64url encoded. #4011

sr1990 opened this issue Aug 2, 2022 · 4 comments · Fixed by #4026
Assignees
Labels
Milestone

Comments

@sr1990
Copy link

sr1990 commented Aug 2, 2022

  • Dash.js version: dev
  • Browser name/version: Chrome
  • OS name/version: MacOS

While trying to play clearkey content, I get the following error:

DRM: unable to create session! --Error generating key request -- TypeError

Failed to execute 'generateRequest' on 'MediaKeySession': 'kids'[0] `is not valid base64url encoded.` Value: oGpvUYhYR/i8Uq2MWlpABg

{TypeError: Failed to execute 'generateRequest' on 'MediaKeySession': 'kids'[0] is not valid base64url encoded. Value: oGpvUYhYR/i8Uq2MWlpABg

Updating the following function resolves the issue

function cencDefaultKidToBase64Representation(cencDefaultKid) {
        try {
            let kid = cencDefaultKid.replace(/-/g, '');
            kid = btoa(kid.match(/\w{2}/g).map((a) => {
                return String.fromCharCode(parseInt(a, 16));
            }).join(''));
            return kid.replace(/=/g, '')
                .replace(/\//g, '_')
                .replace(/\+/g, '-');
        } catch (e) {
            return null;
        }
    }

Function name can be updated to cencDefaultKidToBase64UrlRepresentation

Please let me know if I am missing anything here or
if this is a known issue and
if I should send a PR.
https://github.com/Dash-Industry-Forum/ClearKey-Content-Protection will also need to be updated.

Links:
https://www.w3.org/TR/encrypted-media/#using-base64url
https://www.w3.org/TR/encrypted-media/#clear-key-request-format

Thanks.

@sr1990 sr1990 added the Bug label Aug 2, 2022
@dsilhavy
Copy link
Collaborator

dsilhavy commented Aug 9, 2022

Which stream did you use in your test?

@sr1990
Copy link
Author

sr1990 commented Aug 9, 2022

Hi @dsilhavy,
Unfortunately, I cannot share the stream right now but following are the content protection tags in the mpd:

 <ContentProtection schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc" cenc:default_KID="A06A6F51-8858-47F8-BC52-AD8C5A5A4006"/>
            <ContentProtection schemeIdUri="urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e" value="ClearKey1.0">
                <clearkey:Laurl Lic_type="EME-1.0">http://10.0.0.10:3000/AcquireLicense</clearkey:Laurl>
            </ContentProtection>

Please let me know if you need anything else from the mpd.
Also, I would like to point out that the stream can be played on Shaka player and Android's Exoplayer.

@dsilhavy
Copy link
Collaborator

Thanks, fixed in #4026

@sr1990
Copy link
Author

sr1990 commented Aug 15, 2022

Thanks @dsilhavy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants