gpt4 book ai didi

iOS 允许用户信任某些证书?

转载 作者:行者123 更新时间:2023-11-29 10:40:37 29 4
gpt4 key购买 nike

我正在开发一款专供 IT 企业使用的应用程序。该应用程序将是通过 VM 镜像分发给企业的管理系统的扩展。问题在于 VM 附带自签名证书并被锁定。显然,我在信任 iOS 中的证书时遇到了问题。我知道我可以禁用验证,但这是一个可怕的想法,对于应用商店指定的产品来说毫无意义。所以我想知道,我有什么选择?

最佳答案

I know I can disable validation, but that is a horrid idea and pointless for an app store destined product. So I am left wondering, what are my options?

禁用验证是个坏主意。

你需要实现 -(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace: (NSURLProtectionSpace*)space- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge: (委托(delegate)中的 NSURLAuthenticationChallenge *)challenge 以信任服务器的证书。

Apple 的官方文档位于 Authentication Challenges and TLS Chain ValidationOverriding TLS Chain Validation Correctly .

您可以在 OWASP 的 Certificate and Public Key Pinning 中看到它的示例,在 iOS 示例中。

因为您先验知道服务器的证书应该是什么,所以您可以将它直接编译到您的应用程序中并在运行时利用它。无需费力将它放入 key 链中。

由于您拥有可信的分发 channel (App Store 或组织的企业商店),您不必担心篡改(一些人手放弃)。

另见 How to use NSURLConnection to connect with SSL for an untrusted cert? , 不过要小心。请小心,因为它实际上会通过返回 [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; 来禁用验证。我指出它是因为它是 iOS 功能的 SO 答案。

关于iOS 允许用户信任某些证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24718637/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com