iOS 10.3: Simulator HTTPS localhost: SSL Error

后端 未结 2 476
死守一世寂寞
死守一世寂寞 2020-12-31 16:16

This worked fine for iOS 10.2 and below, but after upgrading to 10.3, when the simulator attempts to connect over HTTPS to the development server running on localhost, the X

2条回答
  •  一整个雨季
    2020-12-31 16:52

    I also had same problem , You have to implement didRecieveChallenge delegate method to handle SSl error

    Add below ;one of code in didReceiveChallenge delegate method of URLSession delegate methods or URLConnnection deleagte method.

    - (void)URLSession :( NSURLSession *)session didReceiveChallenge :( NSURLAuthenticationChallenge *)challenge completionHandler :( void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler {   NSURLSessionAuthChallengeDisposition lDisposition = NSURLSessionAuthChallengeUseCredential;
    NSURLCredential *credential = [[NSURLCredential alloc] init];
    
    
    if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) {
        credential = [NSURLCredential credentialForTrust: challenge.protectionSpace.serverTrust];
        lDisposition = NSURLSessionAuthChallengeUseCredential;
    }
    completionHandler(lDisposition, credential);}
    

提交回复
热议问题