Skip to content

Commit

Permalink
fix(drm): Fix application of DRM server certificate
Browse files Browse the repository at this point in the history
We were previously creating sessions (through filterManifest) before
setting the server certificate (in attach).  This meant the server
certificate was not being used because the license request was created
too early.

Now we will set the server certificate as soon as MediaKeys is
created, ensuring that it is available for all sessions, no matter
when they are created.

Closes shaka-project#2644

Change-Id: I0a04b41c2dee16284375fe1e44b31af9c41cd416
  • Loading branch information
joeyparrish committed Oct 7, 2020
1 parent f7aacf1 commit acc4c0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ shaka.media.DrmEngine = class {
exception.message));
});

const setServerCertificate = this.setServerCertificate();
await Promise.all([setMediaKeys, setServerCertificate]);
await setMediaKeys;
this.destroyer_.ensureNotDestroyed();

this.createOrLoad();
Expand Down Expand Up @@ -860,6 +859,9 @@ shaka.media.DrmEngine = class {

this.mediaKeys_ = mediaKeys;
this.initialized_ = true;

await this.setServerCertificate();
this.destroyer_.ensureNotDestroyed();
} catch (exception) {
this.destroyer_.ensureNotDestroyed(exception);

Expand Down
5 changes: 4 additions & 1 deletion test/media/drm_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,10 @@ describe('DrmEngine', () => {
config.advanced['drm.abc'] = createAdvancedConfig(cert);
drmEngine.configure(config);

await initAndAttach();
const variants = manifest.variants;
await drmEngine.initForPlayback(variants, manifest.offlineSessionIds);

// Should be set merely after init, without waiting for attach.
expect(mockMediaKeys.setServerCertificate).toHaveBeenCalledWith(cert);
});

Expand Down

0 comments on commit acc4c0e

Please sign in to comment.