NSURLConnection Error code (-1202,1012)

别说谁变了你拦得住时间么 提交于 2019-12-06 16:09:11

问题


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.

The Error Code:

-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.

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

Thanks in advance.


回答1:


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;
}


来源:https://stackoverflow.com/questions/19494971/nsurlconnection-error-code-1202-1012

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!