如何从SecCertificateRef和PrivateKey获取SecIdentityRef? [英] how to obtain SecIdentityRef from SecCertificateRef and PrivateKey?

查看:705
本文介绍了如何从SecCertificateRef和PrivateKey获取SecIdentityRef?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您在iOS中拥有SecCertificateRef和私钥,如何创建SecIdentityRef?
我有一个从服务器和相关私钥传递的X509证书,但现在我很难在 NSURLCredentials 中建立信任。

How to create a SecIdentityRef if you have a SecCertificateRef and Private Key in iOS? I have a X509 certificate which is passed from server and an associated private key, but now I am struggling to establish trust in NSURLCredentials.

这里也提出了类似的问题
如何在iPhone钥匙串中建立SecIdentityRef? (没有.p12)

A similar question was asked here How to establish a SecIdentityRef in an iPhone keychain ? (Without a .p12)

如上所述重要提示,我确实使用 SecCertificateCreateWithData 首先使用 SecItemAdd 添加到钥匙串中,但不知道现在要做什么来生成SecIdentityRef。

As mentioned IMPORTANT in above post, i did create SecCertificateRef using SecCertificateCreateWithData first and then added into the keychain using SecItemAdd but don't know what to do now to generate SecIdentityRef.

非常感谢,

Manish


PS - 我没有足够的参考点来评论帖子,所以问了一个新问题。

Many Thanks,
Manish
P.S. - I don't have enough ref points to comment on a post so asking a new question.

推荐答案

据我了解, SecIdentityRef s不作为单独的钥匙串条目存在。当您使用 SecItemCopyMatching()获取标识时,它会找到证书和相应的私钥,并返回一个标识,该标识只是对该(cert,key)对的引用。据我所知,创建 SecIdentityRef 的唯一方法是将一个私钥和一个证书插入你的钥匙串,然后搜索身份。

As I understand it, SecIdentityRefs don't exist as individual keychain entries. When you get an identity using SecItemCopyMatching(), it finds a certificate and a corresponding private key and returns an identity which is just a reference to that (cert, key) pair. As far as I know the only way to create SecIdentityRef is to insert a private key and a certificate for that key into your keychain and then perform a search for identities.

这篇关于如何从SecCertificateRef和PrivateKey获取SecIdentityRef?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆