I want to remove certificate from keychaine using:
let removeKeyQuery: [String: Any] = [kSecClass as String: kSecClassKey,
kSecAttrLabel as String: "serverCertificate"]
let status = SecItemDelete(removeKeyQuery as CFDictionary)
I get the error errSecItemNotFound.
And when I try to save it using:
let getquery: [String: Any] = [kSecClass as String: kSecClassCertificate,
kSecAttrLabel as String: "serverCertificate",
kSecReturnRef as String: kCFBooleanTrue]
var item: CFTypeRef?
let status = SecItemCopyMatching(getquery as CFDictionary, &item)
guard status == errSecSuccess else { print("Certificate not found")
return nil
}
let certificate = item as! SecCertificate
I get errSecSuccess and i get the certificate.