参考链接
iOS 9 HTTPS适配
http://www.jianshu.com/p/b03ae4a1a2d3
IOS Https适配摸索
http://www.jianshu.com/p/f312a84a944c
关于https的简介和说明我都是参考下面的文章:(谢谢文章作者)
1.http://my.oschina.net/vimfung/blog/494687
2.http://oncenote.com/2014/10/21/Security-1-HTTPS/
3.http://blog.csdn.net/dachao_me/article/details/48624685?ref=myread
马上就要2017年1月1号, 不知苹果会如何限制http类的接口,所以适配https还是早作打算
上面的链接基本看一遍 ,应该就能做好适配,而且如果只是简单的对部分接口做https 那应该不会太难
1.首先你要问后台拿到证书(jks格式/Mac:.cer格式) ,或者你可以打开请求的完整链接 在Mac上下载该证书 (导入Xcode工程)
2.删除之前为了跳过https而在plist.info里面的key
3.在AFNetWorking3.0 中 添加获取证书
-(void)getHttpsImageInfo{
NSString *striCer = [[NSBundle mainBundle] pathForResource:@"StartCom Certification Authority" ofType:@"cer"];
NSData *data = [NSData dataWithContentsOfFile:striCer];
NSSet *set = [NSSet setWithObject:data];
AFSecurityPolicy *securityPplicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
securityPplicy.allowInvalidCertificates = YES;
securityPplicy.validatesDomainName = YES;
[securityPplicy setPinnedCertificates:set];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
// manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"image/png", nil];
[manager GET:@"https://www.jiefengpay.com:8443/app/andorid/1.png" parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
NSLog(@"********************* %@",downloadProgress);
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"%@%@",responseObject,[responseObject class]);
NSData *data = responseObject;
UIImage *image = [UIImage imageWithData:data];
UIImageView *vi = [[UIImageView alloc] initWithImage:image];
vi.frame = [UIScreen mainScreen].bounds;
[[UIApplication sharedApplication].keyWindow addSubview:vi];
NSLog(@"++++++++++++++++++++++++++++++++++");
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@",error);
}];
}