I'm handling the server trust authentication challenge in a custom way (comparing the public key from the server trust with a hashed local version) through the urlSessionDelegate
, similarly to how it is done here:
How do I accept a self-signed SSL certificate using iOS 7's NSURLSession and its family of delegate methods for development purposes?
As described in the documentation, I need to cancel the challenge if I want to fail the server trust authentication myself. When doing this, my data task will complete with the NSURLErrorCancelled
. I have some error handling classes which look at the resulting NSURLError
returned by the datatask, and it would be a lot cleaner for me if I got NSURLErrorServerCertificateUntrusted
instead.
Is there a way to achieve that? Or will those server errors only be forwarded when the authentication is handled automatically, without the delegate methods?