Solved!
It turns out that NSURLConnection behaved correctly, i.e. didReceiveAuthenticationChallenge: called for each authentication.
The problem was that the server did not send calls after the first. This turned out because the server set the cookie.
You can force a new call to simply delete the cookie. Since there are no other useful files for this server, I will simply delete them all:
- (void)clearCookiesForURL { NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; NSArray *cookies = [cookieStorage cookiesForURL:_URL]; for (NSHTTPCookie *cookie in cookies) { NSLog(@"Deleting cookie for domain: %@", [cookie domain]); [cookieStorage deleteCookie:cookie]; } }
source share