有关UIWebView的SSL总结

时间:2014-10-10 13:08:44   收藏:0   阅读:315

在网上找了很多文章差不多都是一样的,基本上都是关于NSURLConnection的文章。现在把几个比较好的连接分享给大家http://blog.csdn.net/pingchangtan367/article/details/8264858 、http://www.cocoachina.com/ask/questions/show/97761 ,这个是总结比较好的文章。

还有一种方法就是ios7出现的,文章不多,是NSURLSession的使用。参考:http://blog.csdn.net/kyfxbl/article/details/25713681?reload

用的2这种方法都无法完成,第二种方法使用时,服务端收不到任何请求。直接拦截掉了,后面在研究下。

目前使用的是第一种方法,问题可能是url不是标准的https的。现在是直接读取得到的data..。[m_webViewloadHTMLString:str baseURL:nil]; 用


[m_webView loadRequest:m_request];这个方法是加载不到内容的。会显示"INVALID_TOKEN”。

下面在介绍个NSURLConnection的方法,这个方法没有实验成功。

NSOperationQueue *_queue = [[NSOperationQueue alloc]init];
[NSURLConnection sendAsynchronousRequest:m_request queue:_queue  completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
            if (connectionError) {
                NSLog(@"Httperror:%@%ld", connectionError.localizedDescription,(long)connectionError.code);
            }else{
                //NSInteger code=[(NSHTTPURLResponse*)response statusCode];
           //          NSLog(@"didReceiveResponse....code=%ld",(long)code);
                NSString *str=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
                //NSLog(@"didReceiveData....data=%@",str);
                [m_webView loadHTMLString:str baseURL:nil];
            }
        }];


参考:https://developer.apple.com/library/prerelease/iOS/documentation/Foundation/Reference/NSURLSessionConfiguration_class/index.html#//apple_ref/occ/instp/NSURLSessionConfiguration/TLSMinimumSupportedProtocol、

http://blog.iamzsx.me/show.html?id=155002、http://blog.csdn.net/xyz_lmn/article/details/8968182、http://blog.csdn.net/shouqiangwei/article/details/25897941、http://objccn.io/issue-5-4/

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!