2

我们的 iPhone 模拟器存在问题,这是由使用此行引起的:

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

当证书被授予挑战时,问题就出现了

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

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

所以现在当我们运行应用程序时,我们再也不会遇到身份验证挑战了,这很奇怪,即使我们将凭证更改为

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

or even

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

总结一下:

通过使用 credentialpersistencepermanent,凭证以某种方式保存在某个地方,并自动用于访问我们需要对自己进行身份验证的任何地方。

因此,出于测试目的,我们真的很想删除这个持久的……凭证。

有什么想法吗?:)

4

2 回答 2

4

您是否尝试过重置模拟器?它在模拟器菜单中。

于 2011-06-04T15:42:41.167 回答
2

它保存在钥匙串中。要从NSURLCredentialPersistencePermanent一个不太永久的状态(如NSURLCredentialPersistenceForSession),您必须删除它并重新创建它。

请注意,在某些版本的工具中,重置模拟器不会清除钥匙串。

于 2013-07-25T08:06:59.037 回答