NSURLCredentialStorageRemoveSynchronizableCredentials

Hi,


i'm trying to delete credentials info on logout of app, according to apple docs the method: - removeCredential:forProtectionSpace:options should be used when "trying to delete a credential that has the

NSURLCredentialPersistenceSynchronizable
policy".


My method is as follows:

NSDictionary *credentialsDict = [[NSURLCredentialStorage sharedCredentialStorage] allCredentials];       
if ([credentialsDict count] > 0) {
     NSEnumerator *protectionSpaceEnumerator = [credentialsDict keyEnumerator];
     id urlProtectionSpace;      
     while (urlProtectionSpace = [protectionSpaceEnumerator nextObject]) {
          NSEnumerator *userNameEnumerator = [[credentialsDict objectForKey:urlProtectionSpace] keyEnumerator];
          id userName;
          while (userName = [userNameEnumerator nextObject]) {
               NSURLCredential *cred = [[credentialsDict objectForKey:urlProtectionSpace] objectForKey:userName];
               NSLog(@"cred to be removed: %@", cred);
               NSDictionary * optionsDict = [[NSDictionary alloc] initWithObjectsAndKeys:@YES, NSURLCredentialStorageRemoveSynchronizableCredentials, nil];
               [[NSURLCredentialStorage sharedCredentialStorage] removeCredential:cred forProtectionSpace:urlProtectionSpace options:optionsDict];
          }
     }
}


I just can't seem to remove the info.

I moved you to Core OS > Networking because this is all about networking and security APIs, as opposed to the Objective-C language itself.

What platform are you running on?

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Ok Thanks eskimo,

this relates to the iOS platform

What OS versions have you tried this on?

Do you have iCloud Keychain turned on?

Testing on the device or the simulator?

Ultimately the -removeCredential:xxx call results in a call to SecItemDelete. You could set a symbolic breakpoint on that to see a) whether it's called, and b) whether the parameters look reasonable.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Tested it on ios7, iCloud Keychain is turned off. Testing on a device. I've set a breakpoint after calling the removeCredential method and its not being removed.

Apologies for the late reply, but I'm not being notified of your replies even though I'm following this thread.

iOS 7? That's really old and, more pertinently, immediately after we added iCloud Keychain, which is what all of this 'synchronizable' stuff relates to. Can you retry on something more modern?

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
NSURLCredentialStorageRemoveSynchronizableCredentials
 
 
Q