Consider using an NSURLConnectionDataDelegate that is implementing didReceiveAuthenticationChallenge
.
If the delegate receives an authentication challenge and the protectionSpace is NSURLAuthenticationMethodClientCertificate
and instead of providing one simply does the following.
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
The server has two options.
If it wants to require the certificate, it can simply terminate the connection and the iOS NSURLConnection will raise the error
NSURLErrorClientCertificateRequired
.If the server wants to continue, it can simply do so by not severing the connection and the delegate should receive another call to
didReceiveAuthenticationChallenge
.
I have not been able to concretely verify this hypothesis. I suppose it's possible the iOS NSURL stack can get in the way as well. But I'm looking for some kind of verification on the hypothesis.