iosswiftavplayercertificate-pinning

Using pinned certificates with AVPlayer in iOS


Is there a way to get AVPlayer to enforce certificate pinning in iOS?

Our video loading code is basically:

let url = URL(string: "https://www.example.com/file.mp4")!
let item = AVPlayerItem(url: url)

We're able to do certificate pinning with URLSession using this delegate method: https://developer.apple.com/documentation/foundation/urlsessiondelegate/1409308-urlsession. But I haven't been able to figure out an analogous approach for AVPlayer, if there is one.

Thanks for your help!


Solution

  • If SSL (TLS) pinning is configured through Info.plist, i.e. using NSAppTransportSecurity, as described in Apple's Identity Pinning: How to configure server certificates for your app post, it automatically becomes applied to AVPlayer's streams.

    However, I don't have a source from Apple confirming this; only my own testing with Proxyman.