簡體   English   中英

NSURLCredential 是永久的嗎?

[英]NSURLCredential is permanent?

我們的 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,憑證以某種方式保存在某個地方,並自動用於訪問我們需要對自己進行身份驗證的任何地方。

因此,出於測試目的,我們真的很想刪除這個持久的……憑證。

有什么想法嗎? :)

您是否嘗試過重置模擬器? 它在模擬器菜單中。

它保存在鑰匙串中。 從 NSURLCredentialPersistencePermanent 到NSURLCredentialPersistencePermanent到不太永久的 state 像NSURLCredentialPersistenceForSession ,你必須刪除它並重新創建它。

請注意,在某些版本的工具中,重置模擬器不會清除鑰匙串。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM