如何在钥匙串中保存CFUUID [英] How to save CFUUID in keychain
问题描述
我正在开发一个iPhone应用程序。
应用程序访问某些Web服务,其他东西应该识别设备ID。
I'm developing an iPhone application.
The application access some web service that aboug other things should recognize the device ID.
由于不推荐使用UDID,我需要调用CFUUIDCreate为此生成我自己的UUID。
Since UDID is deprecated, I need to call CFUUIDCreate to generate my own UUID for this purpose.
该ID是安全敏感的:我的所有网络通信都是加密的,我不希望任何人,但我的证书认证服务器知道UUID。
此外,我希望这个标识符能够在重新安装后继续存在。
使用钥匙串存储UUID似乎是一个明显的解决方案。
The ID is security-sensitive: all my network communication is encrypted, and I don't want nobody but my certificate-authenticated server to know that UUID.
Besides, I want this identifier to survive re-install.
Using the keychain to store that UUID seems like an obvious solution.
我该怎么做?
在互联网上,有一些示例如何存储用户名和&钥匙串中的密码。我既没有用户也没有密码,只有16个字节的UUID(或单个NSString)。
On the internets, there're some samples how to store user name & password in keychain. I have neither user nor password, just 16 bytes UUID (or a single NSString).
我需要使用哪个kSecClass?
哪个我需要设置和检索属性吗?
哪些属性是可选的,哪些是必需的?
Which kSecClass do I need to use?
Which attributes do I need to set and retrieve?
Which attributes are optional and which are mandatory?
什么标头/框架定义了CSSM_ALGORITHMS?
文档提到cssmtype.h,xcode autocompletion有< Security / cssmtype.h>但xcode编译器说找不到文件。
What header/framework defines the CSSM_ALGORITHMS?
The doc mentions cssmtype.h, xcode autocompletion has <Security/cssmtype.h> however the xcode compiler says "file not found".
从常识来看,身份应该最合适。然而,文档说身份是私钥和证书的组合,我没有。另外,我没有看到关键字节属性。
From the common sense, "Identity" should fit best. The docs however say "an identity is the combination of a private key and a certificate", I have neither of them. Also, I don't see the "key bytes" attribute.
提前致谢!
推荐答案
您可以使用 SSKeychain 包装器。另请参阅此问题的答案以获取一些基本用法:
如何为SSKeychain选择帐户和服务价值
You could use the SSKeychain wrapper. Also check out the answer on this question for some basic usage stuff: How to choose account and service values for SSKeychain
这篇关于如何在钥匙串中保存CFUUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!