I have a use-case where my iOS application performs authentication with the server using a client certificate. It uses NSURLConnection to perform a server request and submits the client certificate when it receives an authentication challenge.
In one particular flow, the app "retires" and registers again with the server, and in this process generates a new client certificate. However, when it tries to perform the server request, the old certificate is submitted and the app does not receive a challenge. I believe this is related to the KB article https://developer.apple.com/library/ios/qa/qa1727/_index.html, that explains how credentials can be cached.
It suggests that the solution is change ip-address, dns-name or port number to miss the cache. In my case, I can't change any of the above or append a "." or "#", is there any other hack I can perform?
For your use case, the best solution is to convert your code to use NSURLSession. Not only because it will solve your problem but also because NSURLConnection is now deprecated in iOS 9.
NSURLSession will perform a separate authentication for each session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With