Fairplay: MediaError with code 3 in Safari on MacOS

Hello,


I am trying to play Muxed/encrypted/main.ts from the Test Streams provided by Apple with Fairplay key delivery.

Here is what my setup looks like:

- I modified Muxed/encrypted/prog_index.m3u8 to use Fairplay
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://<my_ksm_url>",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"

- I hardcoded my KSM to always return Content Key = 0x3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C and IV = 0xD5FBD6B82ED93E4EF98AE40931EE33B7 and HDCP is set to be not required (0xEF72894CA7895B78)

- My HTML5 client looks like what's provided by Apple - mac_client/FPS_in_Safari_Example.html with minor modifications - I make a POST request to the KSM, and No Pragman request header.


Output:

- I get the video player with the play button crossed like shown here in Figure 1 https://developer.apple.com/library/content/technotes/tn2454/_index.html

- Further debugging the client shows the certificate is acquired, the webkitneedkey event is triggered, the key session is created with init data, webkitkeymessage event is triggered, license request is issued, key session is updated with Uint8Array license, and the webkitkeyadded event in triggered. Eventually the error event on the video element is triggered with MediaError code: 3 which is the code for MEDIA_ERR_DECODE. Note that no webkitkeyerror event is triggered.


Further debugging:

- Assuming that it's a content authoring issue, I modified my playlist to use keyformat of identity.

#EXT-X-KEY:METHOD=SAMPLE-AES,URI="key.bin",KEYFORMAT="identity",IV=0xD5FBD6B82ED93E4EF98AE40931EE33B7

where key.bin contains the binary equivalent of 0x3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C3C

Surprisingly the content played successfully with above modification indicating that there are no issues with content authoring.

- I double checked my KSM and D function implementations. They pass all the tests provided by the Apple. As instructed in https://developer.apple.com/library/content/technotes/tn2454/_index.html I used arbitrary content key and IV and ensured the output CKC has the correct IV and Key

- I double checked my deployment credentials are correct.

- I removed the HDCP TLLV from CKC, and tried with Type 0 and Type 1 but it didn't change the result.


macOS Version is 10.12.6 and Safari version is Version 11.0.2 (12604.4.7.1.4)


At this point, I am not sure what else I can try. Any help is appreciated. Thanks!

Accepted Reply

I was able to resolve this issue by fixing a bug in my KSM implementation. My KSM wasn't extracting an unknown return tag properly from SPC which resulted in wrong value for that tag in CKC.

Replies

Another observation:


In SPC in above setup (Safari on MacOS),


Protocol version used = 1 (TLLV: 5d81bcbcc7f61703 000000a0 00000004 00000001)

Protocol version supported = 1 and 2 (TLLV: 67b8fb79ecce1a13 00000030 00000008 0000000100000002)


Fairplay Streaming PG says - If the Apple device is not using the most recent common version, the app may be trying to attack FPS security.

It also says above does NOT follow good practices. Could that be the reason why client is giving me decoding error and refusing to play the stream?


I was able to resolve this issue by fixing a bug in my KSM implementation. My KSM wasn't extracting an unknown return tag properly from SPC which resulted in wrong value for that tag in CKC.

Hi aaani,

We seem to be having a problem similar to yours.


Do you mind sharing which tag you didn't copy correctly?

Regards,

Anders