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