[英]UIWebView+AFNetworking issue
我使用以下代码:
webView.loadRequest(request!, progress: nil, success: { (responce, html) in
print("\n\n\nsuccess responce = ", html)
return html
}, failure: { (error) in
print("\n\n\nerror = ", error)
})
但是我的服务器的SSL证书无效。 所以我需要设置一个安全策略。 在我那样做之前:
[AFHTTPRequestOperationManager manager].securityPolicy.allowInvalidCertificates = YES;
但是在AFNetworking 3中,不再有AFHTTPRequestOperationManager
类。 如何为AFNetworking 3中的所有请求设置安全策略?
AFHTTPRequestOperationManager的AFNetworking 3等效AFHTTPRequestOperationManager
是AFHTTPSessionManager
。
因此,您应该在webView本身上使用它:
webView.sessionManager.securityPolicy.allowInvalidCertificates = YES;
当然,另一种解决方案是修复服务器上的无效证书。
你可以做,
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.securityPolicy.allowInvalidCertificates = YES;
参考: AFNetworking
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.