【发布时间】:2015-09-24 13:18:55
【问题描述】:
我正在创建使用 HTTPS 上托管的 rest API 的 iOS 应用程序。此域具有 有效的 CA 批准证书,适用于 SSL 和 TLS。但是,当我从我的应用程序发出 NSURL 请求时,它第一次运行良好,但半小时后,当我发出 NSURL 请求时,它返回 NSURL 错误 -1012。
我还尝试使用以下提到的方法处理 身份验证挑战 和 TLS 链验证: - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
当我调试 canAuthenticateAgainstProtectionSpace 并检查 protectionspace 值时,它显示的请求存在 NSURLAuthenticationMethodServerTrust 问题。
我尝试了不同的不同方案来处理这个问题。 1. 在 canAuthenticateAgainstProtectionSpace 方法中,如果我发现 NSURLAuthenticationMethodServerTrust 验证然后我返回 NO,然后 didReceiveAuthenticationChallenge 方法从未调用但 API 返回空白字符串。 2. 在 canAuthenticateAgainstProtectionSpace 方法中,如果我发现 NSURLAuthenticationMethodServerTrust 验证然后我返回 YES,然后调用 didReceiveAuthenticationChallenge 方法并且当我使用 continueWithoutCredentialForAuthenticationChallenge strong>,performDefaultHandlingForAuthenticationChallenge 和 cancelAuthenticationChallenge 方法一一但什么也没发生我得到相同的结果空白字符串,并且在 cancelAuthenticationChallenge 我得到 NSURL 错误 -1012 。
我们的 API 托管在 http://uat-exchange.vrmco.com/
请帮我解决我所缺少的或者我们需要用来解决此错误的任何东西。
提前致谢。
【问题讨论】:
标签: nsurlconnection nsurl nsurlconnectiondelegate