错误域=NSURLError域代码=-1202 iPhone



我得到以下错误:

错误域=NSURLError域代码=-1202";此服务器的证书无效。你可能正在连接一个伪装成"api.linkedin.com"的服务器,这可能会使你的机密信息面临风险"用户信息=0x1c53e630

这在模拟器上运行良好,但在设备上它给出了上述错误。

请帮助纠正。

这是需要更改日期和时间的设备设置,并将其自动设置为当前时区的ON。

试试这个代码:

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
  if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
if ([trustedHosts containsObject:challenge.protectionSpace.host])
  [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
 [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}

希望对有帮助

最新更新