Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didReceiveAuthenticationChallenge not getting called

Tags:

ios5

I am using iOS sdk5.0. I am hitting a link using NSURLConnection and creating a request. But my control is not going into didReceiveAuthenticationChallenge method. Is didReceiveAuthenticationChallenge not called in iOS5.0?

like image 476
anshul Avatar asked Nov 04 '11 13:11

anshul


2 Answers

According to Docs of NSURLConnectionDelegate

connection:canAuthenticateAgainstProtectionSpace:
connection:didReciveAuthenticationChallenge:
connection:didCancelAuthenticationChallenge:

are deprecated and new code should adopt

connection:willSendRequestForAuthenticationChallenge

The older delegates will still be called for compatibility, but incur more latency in dealing with the authentication challenge.

like image 61
Himanshu A Jadav Avatar answered Oct 14 '22 14:10

Himanshu A Jadav


I was having the same problem (see my comment above). In my searches, I came across this gist: https://gist.github.com/1675763 . I tried the code in the AUTH_NEW path. The delegate still wasn't being called. Then I noticed the comment on line 40: "Perhaps iOS 5 can't support DSA signature algorism."

I did some searches, and found nothing to indicate that this was a limitation was a problem. Finally, in desperation, I changed this. I was using java's keytool (Java's reinvented version of openssl+) to generate my self-signed cert. It uses DSA by default. Out of desperation, I used a flag to force it to use RSA. Then the delegate got called, and the code in the gist above worked.

I still have yet to see any documentation that says you can't use DSA. openssl seems to use RSA by default, so folks using that probably never run into this.

Short story: check your cert and make sure it is signed with RSA and not DSA.

like image 1
Chris Westin Avatar answered Oct 14 '22 14:10

Chris Westin