SecItemAdd () returns errSecInteractionNotAllowed (-25308)

Any attempts I make to store the value in the keychain fail with error code errSecInteractionNotAllowed (-25308). I was playing around with Touch ID and keychain, so I might have changed the resolution that I was not aware of, but I cannot figure out what I could change that might be causing this problem.

I was able to successfully store the value in the keychain prior to my conversation with the key chains, so this is most likely a setting somewhere in the device. If it is a parameter, I would like some help to detect what I need to change in order to store the data in the keychain again. Also, I would like to get some suggestions to make sure I have persistence access to the keychain before I try.

static NSString *serviceName = @"myServiceName";

- (void) createTouchIdKeyChain:(NSString *)identifier password:(NSString*)password{
CFErrorRef error = nil;
SecAccessControlRef sacObject =
SecAccessControlCreateWithFlags( kCFAllocatorDefault,
                                kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly,
                                kSecAccessControlUserPresence,  &error);

NSData* secret = [password dataUsingEncoding:NSUTF8StringEncoding];

NSDictionary* attributes = @{
                             (__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
                             (__bridge id)kSecAttrService: serviceName,
                             (__bridge id)kSecAttrAccount: identifier,
                             (__bridge id)kSecValueData: secret,
                             (__bridge id)kSecAttrAccessControl: (__bridge id)sacObject,
                             (__bridge id)kSecUseOperationPrompt: @"create password test"
                             };
OSStatus status = SecItemAdd((__bridge CFDictionaryRef) attributes, nil);
ODLog(@"done");
}

      

+3


source to share


1 answer


In my case, if you try to store two items with the same ID in the keychain, the second attempt will fail with error -25308. Try deleting the first one and try again.



+1


source







All Articles