title: NSURLSession didReceiveChallenge only called once
body: <p>I'm using NSURLSession <code>dataTaskWithRequest:completionHandler:</code> to make some requests to my server. I'm using a self-signed certificate, so when the delegate's <code>URLSession:didReceiveChallenge:completionHandler:</code> gets called, I can do my internal checks to verify it everything is fine.</p>
  
  <p>This all works great on the first request I send. After I call the completion handler with <code>NSURLSessionAuthChallengeUseCredential</code>, then the next requests never call <code>URLSession:didReceiveChallenge:completionHandler:</code>.</p>
  
  <p>For reasons I won't go into in this post, I would really like <code>URLSession:didReceiveChallenge:completionHandler:</code> to be called each time, so that I can do my own checking. I'm assuming NSURLSession is somehow caching the certificate and keeping it in some sort of "valid certificates" list so it's not doing this check each time. I want to clear this cache so that I can make my own check each time. If I restart the App, then <code>URLSession:didReceiveChallenge:completionHandler:</code> does get called once more.</p>
  
  <p>I have tried setting the Credential Storage to nil with no success:</p>
  
  <pre><code>NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  configuration.URLCredentialStorage = nil;
  NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
  [[session dataTaskWithRequest:request
              completionHandler:^(NSData *data,
                                  NSURLResponse *response,
                                  NSError *error) {
  
                  ...
  
              }] resume];
  </code></pre>
  
  <p>Any ideas how to accomplish this?</p>
  
  <p>Thank you!</p>