Error obtaining key request data: AVFoundationErrorDomain reason: Optional("An unknown error occurred (-42650)")

837 views Asked by At

I am implementing Apple Fireplay DRM for delivering encrypted content to devices. I was able to successfully load the certificate, but when I try to obtain SPC data from AVAssetResourceLoadingRequest, I am getting this error.

Error obtaining key request data: AVFoundationErrorDomain reason: Optional("An unknown error occurred (-42650)")

Following is the code to retrieve SPC content

let spcData: Data!

    do {
        /* 
         To obtain the Server Playback Context (SPC), we call 
         AVAssetResourceLoadingRequest.streamingContentKeyRequestData(forApp:contentIdentifier:options:)
         using the information we obtained earlier.
         */
        spcData = try resourceLoadingRequest.streamingContentKeyRequestData(forApp: applicationCertificate, contentIdentifier: assetIDData, options: resourceLoadingRequestOptions)
    } catch let error as NSError {
        print("Error obtaining key request data: \(error.domain) reason: \(error.localizedFailureReason)")
        resourceLoadingRequest.finishLoading(with: error)
        return
    }

I already searched for error code: 42650 on apple developer forum, but no luck!

2

There are 2 answers

0
Hlung On BEST ANSWER

I got this error also. In my case, I was generating the applicationCertificate using the wrong data format (the appIdentifier parameter in resourceLoadingRequest.streamingContentKeyRequestData(forApp:contentIdentifier:options:) function) The certificate that was given to me was base64 encoded. So I need to create data with Data(base64Encoded: yourCertificateString).

0
mamartin On

I also had this issue. Im not using persistent keys, i copy-pasted example code and i forgot to change

AVAssetResourceLoadingRequestStreamingContentKeyRequestRequiresPersistentKey: true to false.

After this it started working.