AFNetworking2.x https 常用代码
2016-01-19 10:10
197 查看
- (AFSecurityPolicy*)customSecurityPolicy { /**** SSL Pinning ****/ NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"你的证书" ofType:@"cer"]; NSData *certData = [NSData dataWithContentsOfFile:cerPath]; AFSecurityPolicy *securityPolicy = [[AFSecurityPolicy alloc] init]; [securityPolicy setAllowInvalidCertificates:NO]; [securityPolicy setPinnedCertificates:@[certData]]; [securityPolicy setSSLPinningMode:AFSSLPinningModeCertificate]; /**** SSL Pinning ****/ return securityPolicy; }
然后在管理器里这么设置
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; /**** SSL Pinning ****/ [manager setSecurityPolicy:[self customSecurityPolicy]]; /**** SSL Pinning ****/ [manager GET:@"网站的url" parameters:params success:^(AFHTTPRequestOperation *operation, NSDictionary* responseObject) { //这里是你自己的代码了 } failure:^(AFHTTPRequestOperation *operation, NSError *error) { //注释同上 }];
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
相关文章推荐
- IOS-http状态码
- AFNetworking https (引用)
- HTTP详解
- TCP/IP协议全解析
- HTTP方法总结
- Mininet模拟不同数据中心的网络拓扑
- 检查网络(并查集)
- 使用chrome浏览器查看当前网页的http头
- HttpWatch工具简介及使用技巧
- Win7下添加网络适配器
- android 检查网络连接状态实现步骤
- 缓存网络数据--Rx和数据库
- 爬虫 - 开发网络爬虫应该怎样选择爬虫框架
- Android编程获取网络时间实例分析
- Java的Socket网络编程基础知识入门教程
- Xcode7 使用NSURLRequest进行HTTP请求出错解决方案
- http servlet服务器和android客户端(二)第一个android客户端
- 使用常见的网络命令查看当前网络状态——Mac OS X篇
- iOS网络-AFNetworking检测网络状态
- Atitit. servlet 与 IHttpHandler ashx listen 和HttpModule的区别与联系 原理理论 架构设计 实现机制 java php c#.net js javascript c++ python