NSURLCredential 是永久的吗?

发布于 2024-11-13 08:32:04 字数 933 浏览 1 评论 0原文

我们的 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,凭证会以某种方式保存在某个地方,并自动用于访问我们需要验证自己的任何地方。

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

有人有什么想法吗? :)

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? :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朕就是辣么酷 2024-11-20 08:32:04

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

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

玩心态 2024-11-20 08:32:04

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文