Using labels on an identity is tricky because identities are not stored in the keychain as an atomic item but are store as a separate private key and certificate, and those items use labels in different ways. Have you tried using a persistence reference here? That is:
SecItemAddwhen you add the identity to the keychain
Save the persistent reference wherever
Later on, when you need the identity back, call
SecItemCopyMatchingwith that persistent reference
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
Im sorry , if I misunderstand,
SecItemAddwhen you add the identity to the keychain"
it mean like this?
query = [ kSecClass as String:kSecClassIdentity, kSecValueRef as String:value2, kSecReturnPersistentRef as String : true as AnyObject ] var returndata:CFTypeRef? let status = SecItemAdd(query as CFDictionary, &returndata) let persitentdata = returnData as! CFData
I tried this, but I got "nil" in returndata...
Am I wrong something?
Finally I could get that
I refered to this discussion https://forums.developer.apple.com/thread/43568
I don't know why but it's work when using SecItemAdd without kSecClass inside query of parameter.
And also when using SecItemCopyMatching without kSecClass , it worked!
thank you for your help!
Thank you sho@jp, Your reply for removing the kSecClass from the SecItemAdd helped me too. I did not remove it from the query for SecItemCopyMatching as it gave me a -50 error (errSecParam). I'd appreciate it if I knew why removing the kSecClass worked and if that's the regular case, the Apple docs should be updated to notify users.
Thank you for opening the bug. I CC'd myself on it to get better insight on where the documentation gaps might be.
DTS Engineering, CoreOS
meaton3 at apple.com