2012-02-28 11 views
1

セキュリティで保護されたHTTPサイトにアクセスするときに書き込まれるNSURLCredentialを削除しようとしています。NSURLCredentialを永久に削除しますか?

NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; 

は、キャッシュされたデータを再ロードしないと、私はこの方法実装しました::

- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse { 
    return nil; 
} 

私は次回実行時に動作し、NSURLCredentialStorageからNSURLCredentialを削除しますが、私はそれを指定していていても、以下のコードアプリケーションdeleteStoredCredentialが "loginSiteName.com"の新しい認証情報を検索して削除します。私の質問は、私が何かを逃している、私はクリアする必要がある他にどこにありますか、資格情報をiPhoneにキャッシュすることができますか?

-(void)deleteStoredCredential { 
    NSURLCredentialStorage *sharedCredentialStorage = [NSURLCredentialStorage sharedCredentialStorage]; 
    NSDictionary *DICT_allProtectionSpaces = [sharedCredentialStorage allCredentials]; 
    // DICT KEY = NSURLProtectionSpace 
    // DICT VALUE = NSDictionary 

    for(NSURLProtectionSpace *thisProtectionSpace in DICT_allProtectionSpaces) { 
     if([[thisProtectionSpace host] isEqualToString:@"loginSiteName.com"]) { 
      NSDictionary *DICT_allCredentials = [sharedCredentialStorage credentialsForProtectionSpace:thisProtectionSpace]; 
      // DICT KEY = NSString (i.e. username) 
      // DICT VALUE = NSURLCredential 

      for(NSString *thisUserName in DICT_allCredentials) { 
       NSURLCredential *credentialToDelete = [DICT_allCredentials valueForKey:thisUserName]; 
       NSLog(@"REMOVE UID: %@ WITH PWD: %@", [credentialToDelete user], [credentialToDelete password]); 
       [sharedCredentialStorage removeCredential:credentialToDelete forProtectionSpace:thisProtectionSpace]; 
      } 
     } 
    } 
} 

答えて

2

私は問題を発見した:私は、サイトにアクセスするために作成NSURLCredentialNSURLCredentialPersistencePermanentの代わりNSURLCredentialPersistenceNoneで作成されました。その結果、資格情報はiPhoneのキーチェーンに保存されていました。

+0

あなたはおそらく1は、キーチェーンからその資格を削除することができる方法を知っています助けるために

のおかげ? – doge

+0

私も同じ問題を抱えています。 NSURLCredentialPersistenceNoneを資格情報に設定しました。何かがまだキャッシュされています。 – lostintranslation

0

また、資格情報をストレージに保存しないようにNSURLCredentialPersistenceNoneも使用しています。 しかし、私は、古いクレデンシャルをクリアして新しいクレデンシャルSSL certificatクライアントを開始するために、10秒のようないくつかのsecondeを待つ必要があることを言います。

NSURLConnectionクラスでこの奇妙な動作を確認してください。あなたは:)

関連する問題