urlSession- didReceive challenge - is not working the same way as the NSURLConnection - willSendRequestFor challenge

We are trying to migrate from NSURLConnection
to URLSession. But for some reason the challenge part in the delegate methods are working differently in these two frameworks.

The webservice endpoint server of ours need a SSL cert for trust along with BASIC Auth. In NSURLConnection, I can see that the "NSURLAuthenticationMethodClientCertificate" challenge is requested by the server and the code sends the p12 file and works perfect.

But in URLSession, I can see only this challenge is coming thru - "NSURLAuthenticationMethodServerTrust" and even If I send the P12 file for this challenge, i do not get any response. I have mentioned this to my webservice endpoint server.
How do you resolve the server trust authentication challenge? You should resolve it with NSURLSessionAuthChallengePerformDefaultHandling. Likewise for any other challenge you don’t care about.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
That worked with some other tweaks. I had to use urlsession dataTask with URLRequest and completion Handler instead of using the delegate methods of the "NSURLSessionDelegate, NSURLSessionDataDelegate, NSURLSessionTaskDelegate" for didReceiveResponse, didReceiveData and didCompleteWithError.


The only delegate methods I am using is didReceiveChallenge

The only delegate methods I am using is didReceiveChallenge

That’s absolutely fine. When you use the convenience methods the session doesn’t issue delegate callbacks that are subsumed by the completion handler but it still issues other delegate callbacks, including both the task and session did-receive-challenge callbacks.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
urlSession- didReceive challenge - is not working the same way as the NSURLConnection - willSendRequestFor challenge
 
 
Q