Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
存在方便的SecCertificateAddToKeychain()功能,它允许开发人员将“浮动”证书(例如SecCertificateRef由 生成的实例SecCertificateCreateWithData())添加到钥匙串。
SecCertificateAddToKeychain()
SecCertificateRef
SecCertificateCreateWithData()
SecKeyRef和SecIdentityRef实例的等效函数在哪里?有SecKeychainItemImport(),但它用于导入原始数据。也有SecItemAdd(),但仅限于添加密码。
SecKeyRef
SecIdentityRef
SecKeychainItemImport()
SecItemAdd()
我错过了什么?
SecItemAdd非常有能力将证书和密钥添加到钥匙串;只需将kSecClass属性设置为项目的类(例如kSecClassKey)并在属性的数组中传递项目引用kSecUseItemList。
SecItemAdd
kSecClass
kSecUseItemList
唯一需要注意的是,一次调用SecItemAdd只能添加同一类的项目;如果要添加证书和密钥,则需要在两次调用中完成。
您不需要显式地创建或添加身份到钥匙串;它们是在证书及其私钥都可用时自动创建的隐式构造。