SecTrustEvaluate() 是否在应用程序钥匙串中查找根证书?
文档说:“如果验证叶证书所需的所有证书均未包含在信任管理对象中,则 SecTrustEvaluate 会在钥匙串搜索列表(请参阅 SecTrustSetKeychains)和系统锚证书存储中(请参阅 SecTrustSetAnchorCertificates)搜索证书”。
但是,由于 SecTrustSetKeychains() 在 iOS 上不可用,因此尚不清楚此函数是否也会在应用程序的钥匙串中查找。
The docs say: “If not all the certificates needed to verify the leaf certificate are included in the trust management object, then SecTrustEvaluate searches for certificates in the keychain search list (see SecTrustSetKeychains) and in the system’s store of anchor certificates (see SecTrustSetAnchorCertificates).”
However, since SecTrustSetKeychains() is not available on iOS, it’s not clear whether this function will also look in the application’s keychain.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它现在写在文档中:
来源: SecTrustEvaluate 文档
It's written in the doc now:
Source: SecTrustEvaluate documentation
Apple Devforums 的 eskimo1 如此回答:
默认情况下不是。然而,通过从钥匙串(或任何地方)获取证书并使用 SecTrustSetAnchorCertificates 将它们应用到 SecTrust 对象,可以很容易地做到这一点。
SecTrustEvaluation /将/在您的钥匙串中找到中间证书。
eskimo1 from Apple Devforums answered this so:
Not by default. However, it's easy to make it do this by getting the certificates out of your keychain (or from wherever) and applying them to the SecTrust object using SecTrustSetAnchorCertificates.
SecTrustEvaluation /will/ find intermediate certificates in your keychain.
自从您发布以来似乎已经有一段时间了,所以我不确定您是否仍然需要答案。如果您的用例是“我遇到了
connection:didReceiveAuthenticationChallenge:
,并且我想确保正在评估准确证书,那么您可以使用 iOS 内置信任方法或通过 Foundation API 做更多工作:(请注意,此处并未专门调用 SecTrustEvaulate,但可以很容易地添加它)从那里,您可以迭代完整的证书数组,并将其与挑战服务器信任参考的 SHA1 之类的内容进行比较:
Seems like it's been a while since you posted so I'm not sure if you still need the answer. If your use case is "I'm getting hit with
connection:didReceiveAuthenticationChallenge:
, and I'd like to make sure that exact certificate is being evaluated, then you can either use iOS built-in trust methods or do a bit more work via the Foundation APIs: (note that SecTrustEvaulate is not being called specifically here, but it could be added in quite easily)From there, you can iterate the full array of certs, and compare it to something like a SHA1 of the challenge's server trust reference: