Fairplay SPC returning nil

I'm attemping to use the [AVAssetResourceLoadingRequest streamingContentKeyRequestDataForApp:contentIdentifier:options:error:]; method to obtain an SPC key but I'm getting nil returned to me instead of the intended SPC value. I am mainly referencing the provided example Fairplay application. I'm using an encoded request URL host string as a content identifier and a .DER certificate retrieved from the SPC server as the app data. Has anyone else experienced this issue?


NSString *hostString = [URL host];
NSData *assetId        = [NSData dataWithBytes:[hostString cStringUsingEncoding:NSUTF8StringEncoding] length:[hostString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
NSData *certificate = (obtained via Key Server).

NSError *error;
NSData *SPC = [loadingRequest streamingContentKeyRequestDataForApp:certificate contentIdentifier:assetId options:nil error:&error]

As discussed in the "Interpreting Error Messages" section of the FairPlay Streaming Programming Guide document pg. 27-29, when -streamingContentKeyRequestDataForApp:contentIdentifier:error: fails and returns nil, it sets the outError parameter to an instance of NSError that describes the failure. Another NSError instance is available through the NSUnderlyingErrorKey in the userInfo dictionary of the NSError instance provided by -streamingContentKeyRequestDataForApp:contentIdentifier:error:. This NSError instance provides additional information of interest when debugging an application that tries to obtain an SPC. What is the actual error that is being returned via the NSUnderlyingErrorKey?

The NSUnderlyingErrorKey error I get is as follows:

Error Domain=NSOSStatusErrorDomain Code=-12640 "The operation couldn’t be completed. (OSStatus error -12640.)"


The full error description is as follows:

Error Domain=AVFoundationErrorDomain
Code=-11800 "The operation could not be completed" 
UserInfo=0x170461980
{NSUnderlyingError=0x1740548e0 "The operation couldn’t be completed. (OSStatus error -12640.)",
NSLocalizedFailureReason=An unknown error occurred (-12640),
NSLocalizedDescription=The operation could not be completed}

Which device and iOS version are you working on?


You should verify the various parameters that are being passed to the streamingContentKeyRequestDataForApp method. For example:


- Are you properly providing the certificate in DER format for the appIdentifier parameter?


- What attributes are you specifying for the #EXT-X-KEY tag in your playlist? Refer to the example in the FairPlay Streaming Programming Guide section titled "Preparing Content for FPS" on pg. 33

I'm using an iPhone 5s iOS 8.3. I am passing in a provided certificate in DER format for the appIdentifier parameter. This certificate is used across various applications and it works for those. I've taken a look at the example Fairplay client application provided by Apple and I'm not doing anything essentially different.

Do you have any extra information about thses parameters? Can the identifier be any string or does it have to be specified to a certain domain?

Hi srk,


I'm having the same problem (using the FPS public certificate provided on FPS SDK), but I get a different error:

Both tests run on iPad Air (A1475)

on iOS 8.4 I get error -42783 ("The certificate suplied for SPC is not valid and is possibly revoked").

on iOS 9.0 beta 3 i get error -42784, which there is no documenation of what this means.


Can you help me?


Thanks,

Israel

I ran into that problem, myself. The certificate provided, publicly, with the FPS SDK is not valid for retrieving an SPC on a client device. That cert is only for testing the server-side implementation of the SKD SDK. If you want to retrieve an actual SPC you need to request the deployment kit from Apple and obtain a "real" certificate.

It sounds to me as if this is not an Apple issued FPS certificate you are using? If that is the case, you will need to request the FPS Deployment package at <https://developer.apple.com/contact/fps/> which contains instructions about how to generate your FPS certificate and Application Secret key (ASk) values. This Apple issued FPS certificate can then be used in your client to generate an SPC.


Note also (as discussed by others on this forum) the development certificate (dev_certificate.der) provided in the FPS Server SDK is not for retrieving an SPC on the client device; it is only for testing the key security module implementation. To obtain an SPC on the client you need to use an Apple issued FPS certificate as just discussed.

Thanks, the FPS certificate is currently being actively used by other application so the assumption is that it is a valid certificate. Does the content identifier parameter have to contain certain data or is it simply used as a unique identifier?

The content identifier is used as a unique identifier.


In your playlist, you should use a custom URL scheme for the URI of the EXT-X-KEY tag, something like "skd://key65", as documented in the FPS Programming Guide.

It appears that the playlist does not contain a EXT-X-KEY tag. I hope that fixes it! Thanks!

Fairplay SPC returning nil
 
 
Q