is keychain in ios threadsafe?
Asked Answered
E

2

14

I would like to add some items to the keychain using "secitemadd", but I need to know first, if this is thread safe.

I have read the documentation from apple, but I am unable to find anywhere stating if its thread-safe.

Exhibitioner answered 11/5, 2015 at 14:9 Comment(1)
I am amazed how little documentation there is on this. I would imagine that based on the lack of documentation and issues raises on SO, that the API is probably thread safe.Retharethink
G
21

In another document, Apple says it is thread safe.

Concurrency Considerations
On iOS, all the functions in this API are thread-safe and reentrant.

see Certificate, Key, and Trust Services Reference

Golgotha answered 22/5, 2015 at 10:13 Comment(1)
Quinn explains concurrency in Keychain a bit more in depth in this forum post, might be of interest to anyone looking into this: developer.apple.com/forums/thread/…Tannie
B
1

Keychain isn't thread-safe. If we try to retrieve the keychain information it returns -25300 from time to time in practice. Be careful.

Brasier answered 23/1, 2019 at 10:13 Comment(6)
-25300 = errSecItemNotFound to help those reading; also this answer is only partially accurate -- the accepted answer is accurate. macOS and iOS are different. Here, the question clearly states ios thus this answer is incorrect.Beebread
It may be helpful noting there are other reasons that can cause similar result code.Beebread
@Beebread and what? the question of what about thread saving. Not about any other reason of -25300.Brasier
@Brasier read thisSenna
@Brasier Apple docs state "In iOS, all the functions in this API are thread-safe and reentrant." this is in the Security framework and keychain is part of this framework. I have posted the link above. This is the link to the apple docs once again. May I ask what your reference is?Senna
@Senna I faced the problem where this isn't correct.Brasier

© 2022 - 2024 — McMap. All rights reserved.