HTTPS request in iOS 9 : NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)

后端 未结 6 1806
轮回少年
轮回少年 2020-12-05 15:25

I\'m updating my app to accommodate Apple\'s new ATS. Without any changes to the Plist-Info,the following code throws an error at sendSynchronousRequest() in a

6条回答
  •  暖寄归人
    2020-12-05 16:09

    If your app includes H5 page, sometimes it also will have this error.
    It doesn't only require to turn on Allow Arbitrary Loads to fix it, but also require to add code below in your appDelegate.m:

    
    @implementation NSURLRequest(ATS)
    + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
    {
        return YES;
    }
    @end
    

提交回复
热议问题