My question is, is this an issue even if I'm doing something computationally cheap like checking the certificate's common name?
Yes. The sticking point here is not the computation done in your authentication challenge handler, but the work required to resume (or relaunch) your app in order to run any code.
Imagine you have an app that’s suspended in the background and it receives a silent push notification that tells it to download new content (this is a common scenario for magazine apps, amongst many others). In response it starts N download tasks in a background session. In the absence of a custom authentication challenge handler, the system will happily work away downloading all of those resources and, when they’re all done, resume the app in the background to process the completion handlers. N downloads, 1 resume.
If you introduce an authentication challenge handler the story is not nearly as nice. Before starting a download the system has to resume your app to run your authentication challenge handler. So, for N downloads you need N+1 resumes.
Such resumes are budgeted. Before it resumes your app, the system must allocate the budget for that work. That’s fine for a while but eventually the budget starts to get tight and the system must delay starting your download simply because it doesn’t have the budget to run your authentication challenge handler.
Moreover, the ‘cost’ of resume X+1 is double that of resume X. So each time you resume it gets progressively harder to resume again.
On 23 Oct you wrote:
Over the last three weeks we realized that background sessions do not support non-builtin CAs, and therefore do not support our server authentication.
On 24 Oct I wrote:
You should be able to handle server trust authentication challenges in a background session. However, I strongly recommend against this, for a bunch of different reasons:
…
You will have to disable App Transport Security, which is likely to cause you grief further down the line.
…
On 29 Oct you wrote:
This second point surprised me in a similar way. Is this the case even if we are implementing server trust only in order to make it more demanding than the ATS requirements?
No. If you look at the wider context of my quote you’ll see it was related to custom CAs rather than system-trusted CAs. If the server has a certificate issued by a system-trusted CA, you don’t need to disable ATS to access the server. If you want to use an authentication challenge handler to tighten security, that’s fine (modulo the resume rate limiter issues discussed earlier).
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"