【问题标题】:Error Domain=NSURLErrorDomain Code=-1202 iPhone错误域=NSURLErrorDomain 代码=-1202 iPhone
【发布时间】:2013-08-24 05:11:06
【问题描述】:

我收到以下错误: 错误域=NSURLErrorDomain 代码=-1202 “此服务器的证书无效。您可能正在连接到伪装成“api.linkedin.com”的服务器,这可能会使您的机密信息面临风险。”用户信息=0x1c53e630

这在模拟器上运行良好,但在设备上却出现上述错误。

请帮忙改正。

【问题讨论】:

标签: iphone linkedin


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    试试这个代码:

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

    希望对你有帮助

    【讨论】:

    • 我已经尝试过了,这与我在问题中提到的相同的错误,它在模拟器上工作正常,这个错误只在设备上杀死我。
    • 通过解释解决方案将修复什么来改进这个答案,也许是为了可读性而格式化。
    • 我迷失了一整天才得到它,这是我的设备设置需要更改日期和时间,然后将其自动设置为当前时区。
    • 当你复制this one这样的代码时,你应该给予信任
    猜你喜欢
    • 2017-05-04
    • 2022-07-25
    • 1970-01-01
    • 2017-11-30
    • 2014-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多