How to deal with Invalid Certificate over https (AVPlayer, AVAsset)

Hi everybody,

I’m getting crazy on this.

I made a Radio app (yes another one...) for myself since I love radio and couldn’t find one suitable to me, it works flawlessy except for the (apparently) self signed certified with https.


For example I’d like to play Fox News Radio but iOS keep telling me that they use an “invalid cerficate”, the same for other radio.

I searched everywhere here on SO and around the internet, this is where I arrived:

- I’m using AVURLAsset with AVPlayer;

- I’m using AVAssetResourceLoaderDelegate;

- I set the delegate;

- The func resourceLoader(_ resourceLoader: AVAssetResourceLoader,shouldWaitForResponseTo authenticationChallenge: URLAuthenticationChallenge) -> Bool

is never called;


In general every AVAssetResourceLoaderDelegate function is never called.


Then I found this page:

https://stackoverflow.com/questions/26649865/avassetresourceloaderdelegate-methods-not-working-on-device/43338772

where the user Alex explains that in order to use those functions we must use a fake scheme not “https”: what’s the point behind this? Apple never says to change the schema in its documentation.


Is this the correct approach to bypass the invalid certificate I find?

I’ve tried changing the App Transport Security Settings even for specified domain but it doesn’t work.

Any ideas, suggestion or help will be so appreciated.



Thank you in advance,

Fab

Replies

I have the same problem. Have you solved it?


This issue is killing me too. The workaround seems to be to use a custom scheme instead of http/https, and monkey with the resource loader in the delegate. But that's a extrememly stupid hack. I'm just trying to play videos from my own localhost web server, that uses a self-signed certificate provided by Server.


Any movement on a fix for this in iOS 12?

Have the same problem. Playing an HLS from server with correct certificates - works, and doesn't work for servers with self-signed certificates.

I have Allow Arbitrary Loads set to true in info.plist, so other requests are fine. But when i pass AVPLayer link to .m3u8 file. it doesn't. Says


"Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid."

Any news on this ?

@Scenario, can you explain the hack you're working with, with the ResourceLoaderDelegate ?