2016-11-23 23 views
0

错误9802是根据苹果的docs“致命警报”。我已经看过谷歌和SO,并没有发现任何引用9802修复了这个问题。我可以将我的代码更改为“apple.com”,然后我得到该页面,但使用我自己的URL,我得到上述错误。我试过了我能想到的所有东西,但没有任何效果。有时间寻求帮助! :dHTTP加载失败,我尝试了所有的建议,但没有任何工作

使用

/usr/bin/nscurl --ats-diagnostics https://pragerphoneapps.com

的结果是所有测试失败(结果上传here

这是我的应用程序的.plist文件中的图像(仅适用于相关部分)

enter image description here

并且这是目标信息的图像:

enter image description here

这是我的代码:

- (IBAction)showHTMLHelp:(UIButton *)sender { 

// make the popover 
UIViewController* popoverContent = [UIViewController new]; 
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 450, 500)]; 
popoverView.backgroundColor = [UIColor colorWithWhite:(CGFloat)1.0 alpha:(CGFloat)1.0]; // frame color? 
popoverContent.view = popoverView; 

//resize the popover view shown in the current view to the view's size 
popoverContent.preferredContentSize = CGSizeMake(450, 500); 

NSString *urlAddress = @"https://pragerphoneapps.com";  // @"https://www.pragerphoneapps.com/bookstore-inventory-manager/upload-help/"; 
NSURL *url = [NSURL URLWithString:urlAddress]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 

// add the UIWebView for RichText 
UIWebView *webView = [[UIWebView alloc] initWithFrame: popoverView.frame]; 
webView.backgroundColor = [UIColor whiteColor]; // change background color here 

// add the webView to the popover 
[webView loadRequest:requestObj]; 
[popoverView addSubview:webView]; 

// if previous popoverController is still visible... dismiss it 
if ([popoverController isPopoverVisible]) { 
    [popoverController dismissPopoverAnimated:YES]; 
} 

//create a popover controller 
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent]; 

[popoverController presentPopoverFromRect:((UIButton *)oShowHelp).frame inView:self.view 
       permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

}

+0

它可以与http域一起工作吗?如果是这样,那么问题不可能是你的代码。检查一下; http://stackoverflow.com/questions/38719075/ios-kcfstreamerrordomainssl-9813 –

+0

没有...不适用于http或https;出现此错误:由于App Security Transport Security不安全,因此App Transport Security已阻止明文HTTP(http://)资源加载。临时例外可以通过您的应用程序的Info.plist文件进行配置。 – SpokaneDude

+0

您的目标网站遭到入侵或证书不正确。它甚至不会在Chrome中打开。 –

回答

1

我认真建议您解决您的SSL证书。 ATS要求您拥有有效的SSL证书,TLS 1.2或更高版本并支持正向保密。 这将是2017年初的一项要求,因此更好地做好准备。

无论如何,与此同时尝试以下步骤来实现这一目标。

把这个文件的顶部:

@interface NSURLRequest (InvalidSSLCertificate) 
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host; 
+ (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host; 
@end 

禁用应用程序传输安全中的Info.plist。成功地加载网站

[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]]; 

示例代码:加载请求之前 enter image description here

允许使用无效的SSL证书

NSString *urlAddress = @"https://pragerphoneapps.com";  // @"https://www.pragerphoneapps.com/bookstore-inventory-manager/upload-help/"; 
NSURL *url = [NSURL URLWithString:urlAddress]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]]; 
UIWebView *webView = [[UIWebView alloc] initWithFrame: self.view.frame]; 
webView.backgroundColor = [UIColor whiteColor]; 
[self.view addSubview:webView]; 
[webView loadRequest:requestObj]; 
+0

对不起,没有工作......得到这个:NSURLSession/NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9802) – SpokaneDude

+0

获取SSL证书解决了问题;感谢提示! SD – SpokaneDude

0

我不知道为什么它不能NSAllowArbitraryLoads设置”工作YES “。如果有缓存,请尝试重新启动Mac或Xcode。 而您的“例外域”设置格式错误。

enter image description here

相关问题