I'm working with the OWASP sample for Certificate and Public Key Pinning. The sample uses random.org, and random.org recently got a new certificate. That means connection:didReceiveAuthenticationChallenge:
is failing. That is expected and good :)
However, the failure is displayed as "NSURLErrorDomain", with a code of -1012. That's not very helpful, and a user will not be able to do anything meaningful with it:
It would be much better to supply a message with text similar to "Warning: the public key identifying the website has changed...".
Another little nit: in connection:didFailWithError:
, I cannot tell if the -1012 is due to the pinning failure or another network error. So I would like to supply the message only for the certificate failure, and not other -1012 errors.
How does one supply "rich error information" to the call of [[challenge sender] cancelAuthenticationChallenge: challenge]
(which is called when connection:didReceiveAuthenticationChallenge:
fails). NSURLConnectionDelegate Protocol Reference and NSURLAuthenticationChallengeSender Protocol Reference do not mention how to do so.