Error retrieving key request data: AVFoundationErrorDomain reason: optional ("Unknown error (-42650)")
I am implementing Apple Fireplay DRM to deliver encrypted content to devices. I was able to upload the certificate successfully, but when I try to get SPC data from AVAssetResourceLoadingRequest
I get this error.
Error obtaining key request data: AVFoundationErrorDomain reason: Optional("An unknown error occurred (-42650)")
Below is the code to get 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've already searched for error code: 42650 on the Apple Developers Forum, but no luck!
source to share
I got this error too. In my case, I was generating an applicationCertificate using the wrong data format (the appIdentifier parameter in the function resourceLoadingRequest.streamingContentKeyRequestData(forApp:contentIdentifier:options:)
). The certificate I was provided with was base64 encoded. So I need to create data with Data(base64Encoded: yourCertificateString)
.
source to share