Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS TLS session caching credentials

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?

like image 757
Pooja Bansiya Avatar asked Apr 28 '26 03:04

Pooja Bansiya


1 Answers

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.

like image 108
Daniel Zhang Avatar answered Apr 30 '26 15:04

Daniel Zhang