Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIWebView&x2B;网络问题_Ios_Ssl_Afnetworking_Afnetworking 3 - Fatal编程技术网

Ios UIWebView&x2B;网络问题

Ios UIWebView&x2B;网络问题,ios,ssl,afnetworking,afnetworking-3,Ios,Ssl,Afnetworking,Afnetworking 3,我使用以下代码: 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) })

我使用以下代码:

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中的所有请求设置安全策略?

AFNetworking 3相当于
AFHTTPRequestOperationManager
AFHTTPSessionManager

因此,您应该在webView本身上使用:

webView.sessionManager.securityPolicy.allowInvalidCertificates = YES;

当然,另一种解决方案是修复服务器上的无效证书。

AFNetworking 3相当于
AFHTTPRequestOperationManager
AFHTTPSessionManager

因此,您应该在webView本身上使用:

webView.sessionManager.securityPolicy.allowInvalidCertificates = YES;
当然,另一种解决方案是修复服务器上的无效证书。

您可以这样做

 AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
 manager.securityPolicy.allowInvalidCertificates = YES;
参考资料:

您可以

 AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
 manager.securityPolicy.allowInvalidCertificates = YES;

参考资料:

这将不起作用,因为
[AFHTTPSessionManager]
创建一个未链接到web视图的新管理器。我刚刚给出了选项,而不是
AFHTTPRequestOperationManager
,因为
OP
要求
AFHTTPRequestOperationManager
afnetworking 3.0
中不可用!!OP要求对所有请求设置安全策略!因此他/她可以使用
AFHTTPSessionManager
作为singleton<代码>[AFHTTPSessionManager manager]不会返回单例,它会创建一个新的会话管理器对象。是的,但是我们只能创建一次会话管理器对象,它也可以作为单例使用!这将不起作用,因为
[AFHTTPSessionManager manager]
创建了一个未链接到web视图的新管理器。我刚刚给出了选项而不是
AFHTTPRequestOperationManager
,因为
OP
要求
AFHTTPRequestOperationManager
afnetworking 3.0
中不可用!!OP要求对所有请求设置安全策略!因此他/她可以使用
AFHTTPSessionManager
作为singleton<代码>[AFHTTPSessionManager manager]不会返回单例,它会创建一个新的会话管理器对象。是的,但是我们只能创建一次会话管理器对象,它也可以作为单例使用!