网络:NSURLConnection 使用 HTTPS
来源:互联网 发布:淘宝手机端店招素材 编辑:程序博客网 时间:2024/05/21 19:23
#import "ViewController.h"@interface ViewController ()<NSURLConnectionDelegate,NSURLConnectionDataDelegate>@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.}- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { NSURL *url = [NSURL URLWithString:@"https://mail.itcast.cn"]; // 创建请求 NSURLRequest *request = [NSURLRequest requestWithURL:url]; [NSURLConnection connectionWithRequest:request delegate:self];}// 使用第三方另说// 信任HTTPS证书- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { NSLog(@"%@",challenge.protectionSpace); if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) { // 信任证书 NSURLCredential *cre = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; [challenge.sender useCredential:cre forAuthenticationChallenge:challenge]; }}// 接收到数据- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]);}@end
0 0
- 网络:NSURLConnection 使用 HTTPS
- 使用NSURLConnection获得网络数据
- iPhone网络开发之如何使用NSURLConnection
- iphone:使用NSURLConnection下载网络图片
- iphone:使用NSURLConnection下载网络图片
- iPhone网络开发之如何使用NSURLConnection
- iPhone网络开发之如何使用NSURLConnection
- IOS--简单的网络NSURLConnection的使用
- IOS网络开发之如何使用NSURLConnection
- iPhone网络开发之如何使用NSURLConnection
- 使用NSURLConnection的网络请求与封装
- iPhone网络开发之如何使用NSURLConnection
- iPhone网络开发之如何使用NSURLConnection
- iPhone网络开发之如何使用NSURLConnection
- IOS网络学习-6、NSURLConnection基本使用
- iOS网络开发之NSURLConnection的使用
- iPhone网络开发之如何使用NSURLConnection
- 网络篇 - 02.NSURLConnection基本使用
- 快速排序
- c++实验4-利用循环求和
- C#利用matlab画图
- jvm 参数说明
- php实现伪静态的方法
- 网络:NSURLConnection 使用 HTTPS
- c++作业4
- java web开发 高并发处理
- 自定义导航控制器返回按钮
- 阿里2016笔试(算法春招实习)
- nyoj744 蚂蚁的难题(一)
- 字符串分隔(java实现)
- django应用
- android 三种定位方式