Error Domain=NSURLErrorDomain Code=-1202 iPhone

前端 未结 2 785
情书的邮戳
情书的邮戳 2021-01-13 09:52

I am geting following error: Error Domain=NSURLErrorDomain Code=-1202 \"The certificate for this server is invalid. You might be connecting to a server that is pretending t

相关标签:
2条回答
  • 2021-01-13 10:20

    Try this code:

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

    Hope it helpful

    0 讨论(0)
  • 2021-01-13 10:28

    It is device setting that need to change the date and time , and set it automatically ON for current time zone .

    0 讨论(0)
提交回复
热议问题