NSURLCredential 是永久的吗?
我们的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过重置模拟器?它位于模拟器菜单中。
Have you tried just resetting the simulator? It's in the Simulator menu.
它保存在钥匙串中。要从 NSURLCredentialPersistencePermanent 转变为不太永久的状态,例如 NSURLCredentialPersistenceForSession,您必须删除它并重新创建它。
请注意,在某些版本的工具中,重置模拟器不会清除钥匙串。
It's saved in the keychain. To go from
NSURLCredentialPersistencePermanent
to a less permanent state likeNSURLCredentialPersistenceForSession
, you have to remove it and recreate it.Note that in some versions of the tools resetting the simulator does NOT clear the keychain.