videojs / videojs-contrib-eme

Supports Encrypted Media Extensions for playback of encrypted content in Video.js
Other
203 stars 72 forks source link

HLS + Axinom Fairplay DRM: Invalid license request #95

Closed vvodicka closed 5 years ago

vvodicka commented 5 years ago

Hello, I experienced weird behaviour while trying to implement fairplay straming for iOS devices. My configuration is here:

const srcOptions: any = { src: streamInfo.url, type: 'application/x-mpegURL', keySystems: { 'com.apple.fps.1_0': { certificateUri: 'https://static-test.otta.sk/FP/fairplay.cer', licenseHeaders: { 'X-AxDRM-Message': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb21fa2V5X2lkIjoiMjBDOENEMTQtQzA3MC00NTdDLThDQ0ItNkFFRTY3NDQ0MUQyIiwibWVzc2FnZSI6eyJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsInZlcnNpb24iOjIsImxpY2Vuc2UiOnsiZXhwaXJhdGlvbl9kYXRldGltZSI6IjIwMTktMDktMTJUMDg6Mjc6MjIuODExWiJ9LCJjb250ZW50X2tleXNfc291cmNlIjp7ImlubGluZSI6W3siaWQiOiI5NDUwYjAzMC0wYmIyLWRlYWYtYTc1NC1lYmVhYTExMTEwMjQiLCJpdiI6ImlqQ3hhS04vVzNUSGxQVGQxOHVpUEE9PSJ9XX19LCJ2ZXJzaW9uIjoxfQ.dViF7XSkmePLJTrEu_ysUkT4_Tkm3itYJdMSrE8UJMQ' }, licenseUri: 'https://drm-fairplay-licensing.axprod.net/AcquireLicense' } } };

Seems like certificate is obtained successfully, but there is a problem with AcquireLicense, because I got error: 400 Invalid license request. The key ID contained in the asset ID is not a valid GUID.

URLS and token seems to be fine, since it works on axinom's testing page: https://vtb.axinom.com/fairplay_streaming_sample_player.html?url=https%3A%2F%2Ftowercom-vod-prep-prot.ssl.cdn.cra.cz%2Fvod_Towercom_FP%2F_definst_%2F0048%2F3218%2Fcze-sd1-sd2-sd3-sd4-hd1-hd2-axinom-qFXSivaa.smil%2Fplaylist.m3u8&license=https%3A%2F%2Fdrm-fairplay-licensing.axprod.net%2FAcquireLicense&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjb21fa2V5X2lkIjoiMjBDOENEMTQtQzA3MC00NTdDLThDQ0ItNkFFRTY3NDQ0MUQyIiwibWVzc2FnZSI6eyJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsInZlcnNpb24iOjIsImxpY2Vuc2UiOnsiZXhwaXJhdGlvbl9kYXRldGltZSI6IjIwMTktMDktMTJUMDg6Mjc6MjIuODExWiJ9LCJjb250ZW50X2tleXNfc291cmNlIjp7ImlubGluZSI6W3siaWQiOiI5NDUwYjAzMC0wYmIyLWRlYWYtYTc1NC1lYmVhYTExMTEwMjQiLCJpdiI6ImlqQ3hhS04vVzNUSGxQVGQxOHVpUEE9PSJ9XX19LCJ2ZXJzaW9uIjoxfQ.dViF7XSkmePLJTrEu_ysUkT4_Tkm3itYJdMSrE8UJMQ&certUrl=https%3A%2F%2Fstatic-test.otta.sk%2FFP%2Ffairplay.cer

Could there be a problem with processing the token?

vvodicka commented 5 years ago

nevermind... looks like I only needed to implement cusotm getContentId method to make it work.

Shihab-Github commented 4 years ago

I'm getting the same error too. Can u please share your implementation of custom getContentId method ?

Shihab-Github commented 4 years ago

@wolodo can you please help ?

curt6815463 commented 4 years ago

https://github.com/Axinom/drm-quick-start/blob/82d81dad82b802c4332537f4964835b47601f608/Website/fairplay.html#L225

vvodicka commented 4 years ago

something like this helped:

getContentId: function (emeOptions: any, initData: any) {
                            return arrayToString(initData).replace(/^.*:\/\//, '');
                        },

use it like this:

const desiredKeySystem: IDrmData | undefined = streamInfo.drmInfo.drmFairPlayInfo;

player.src(
            {
                src: streamInfo.url,
                type: StreamingProtocolTypes.HLS,
                // @ts-ignore
                keySystems: {
                    [desiredKeySystem.keySystem]: {
                        certificateUri: desiredKeySystem.certificateUrl,
                        licenseUri: desiredKeySystem.licenseServerUrl,
                        licenseHeaders: {
                            'X-AxDRM-Message': desiredKeySystem.token
                        },

                        getContentId: function (emeOptions: any, initData: any) {
                            return arrayToString(initData).replace(/^.*:\/\//, '');
                        },
                    }
                }
            }
        );