NSURLConnection 错误代码 (-1202,1012) [英] NSURLConnection Error code (-1202,1012)

查看:64
本文介绍了NSURLConnection 错误代码 (-1202,1012)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 NSURLConnection 用于一种现场服务类型 iOS 应用程序,因此应用程序是现场服务类型,有超过 50 个用户,并且有超过 50 个用户可能同时使用该应用程序,这就是为什么有超过 50 或 60 个请求到达服务器.现在我的问题是我经常收到以下两个错误,这意味着每个用户在一天内可能会遇到 5 次以上的错误.所以这对我来说是一个挑战.

I am using NSURLConnection for one field service type iOS appliation, so app is field service type there are more then 50 users and more then 50 users may use the application on same time that's why there are more then 50 or 60 request come to the server. Now my issue is I have received below two errors frequently means every single user can face this error more then 5 times in one day. so it become a challenge for me.

错误代码:

-1202 NSURLErrorServerCertificateUntrusted

-1012 NSURLErrorUserCancelledAuthentication

我搜索了很多,我发现它们是与服务器相关的错误,但我仍然没有任何解决方案来解决这个问题.

I have searched a lot and i found that they are server related errors but still i don't have any solution for how to resolve this problem.

请帮助我如何解决这个 NSURLConnection 错误(-1202 NSURLErrorServerCertificateUntrusted 和 -1012 NSURLErrorUserCancelledAuthentication)问题.

Please help me how can i solve this NSURLConnection error (-1202 NSURLErrorServerCertificateUntrusted and -1012 NSURLErrorUserCancelledAuthentication) problem.

提前致谢.

推荐答案

您需要使用 connectionWithRequest:delegate: 来接受不受信任的证书.

You need to use connectionWithRequest:delegate: to accept untrusted certificates.

您可以实现这些委托方法

You can implement these delegate methods

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
{
    return YES;
}

- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection
{
    return YES;
}

这篇关于NSURLConnection 错误代码 (-1202,1012)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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