2

We have a problem with our iPhone-simulator that was caused by using this line:

    Foo = [NSURLCredential CredentialWithUser:foo 
    password:bar persistance:NSURLCredentialPersistencePermanent];

The problem was created when the credential was given to the challenge over at

        -(NSURLConnection *)connection
        didReceiveAuthenticationChallenge(NSURLAuthenticationChallenge *)challenge
    {

        [[challenge sender]useCredential:Foo forAuthenticationChallenge:challenge]      
    }

So now when we run the application, we dont ever ever again run into the authenticationchallenge again, which is quite odd, even if we change the credential to

    Foo = [NSURLCredential CredentialWithUser:foo 
    password:bar persistance:NSURLCredentialPersistenceForSession];

or even

    Foo = [NSURLCredential CredentialWithUser:foo
    password:bar persistance:NSURLCredentialPersistenceNone];

To summarize:

By using credentialpersistencepermanent the credential is somehow saved somewhere and used automagically to access wherever we need to autenticate ourselves.

So for testing-purposes, we would really like to remove this persistent... credential.

Any ideas anyone? :)

Jens Bergvall
  • 1,617
  • 2
  • 24
  • 54
  • 1
    If someone answers this question by stating that i should only have to reset the iPhone-simulator i'll mark that answer as correct. It actually solved the problem, we just didnt ever think about it. – Jens Bergvall Jun 03 '11 at 11:48
  • 1
    There aren't rules against you posting your own answer :) – Tom Irving Jun 03 '11 at 14:26

2 Answers2

4

Have you tried just resetting the simulator? It's in the Simulator menu.

Philippe
  • 905
  • 6
  • 18
2

It's saved in the keychain. To go from NSURLCredentialPersistencePermanent to a less permanent state like NSURLCredentialPersistenceForSession, you have to remove it and recreate it.

Note that in some versions of the tools resetting the simulator does NOT clear the keychain.

quellish
  • 21,123
  • 4
  • 76
  • 83