iOS 10.3: Simulator HTTPS localhost: SSL Error

后端 未结 2 477
死守一世寂寞
死守一世寂寞 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);}
    
    0 讨论(0)
  • 2020-12-31 17:00

    After installing your self-signed SSL certificate (by dragging and dropping it) onto the iPhone Simulator, go to Settings > General > About > Certificate Trust Settings and enable full trust for your certificate.

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