zumzum
zumzum

Reputation: 20138

What does OSStatus Error -50 mean?

I am writing some keychain code on iOS. When I try to insert an item in keychain I get error -50.

What does OSStatus error -50 mean?

Upvotes: 3

Views: 14943

Answers (3)

mbonness
mbonness

Reputation: 1682

If you are adding a password to the keychain make sure you pass it as Data and not String, otherwise you will get an OSStatus error -50.

static func savePassword(password: Data, account: String) throws -> OSStatus {
    let query = [
        kSecClass as String: kSecClassGenericPassword as String,
        kSecAttrAccount as String: account,
        kSecValueData as String: password
        ] as [String: Any]

    SecItemDelete(query as CFDictionary)

    return SecItemAdd(query as CFDictionary, nil)
}

Upvotes: 9

AStopher
AStopher

Reputation: 4520

Error -50 is a errSecParam, and means that at least one of the parameters you passed in a function was/are not valid.

This can be due to type differences, or perhaps an invalid value. See this page on the Apple site to read the official documentation from Apple on errSecParam.

Upvotes: 2

Maggie
Maggie

Reputation: 8071

It's errSecParam, indicating one or more of your parameters is wrong.

Here: https://developer.apple.com/library/ios/documentation/Security/Reference/keychainservices/index.html#//apple_ref/c/econst/errSecParam

Upvotes: 9

Related Questions