AFNetWorking 3.0 https 忽略证书

2016-05-10  本文已影响1504人  James_Geng

AFHTTPSessionManager*session = [AFHTTPSessionManagermanager];

//session.securityPolicy.allowInvalidCertificates = YES; // not recommended for production

//session.responseSerializer = [AFJSONResponseSerializer serializer];

//session.requestSerializer = [AFJSONRequestSerializer serializer];

//允许非权威机构颁发的证书

session.securityPolicy.allowInvalidCertificates=YES;

//也不验证域名一致性

session.securityPolicy.validatesDomainName=NO;

//关闭缓存避免干扰测试

session.requestSerializer.cachePolicy=NSURLRequestReloadIgnoringLocalCacheData;

[sessionPOST:@"https://139.196.180.54/"parameters:dicprogress:^(NSProgress*_NonnulluploadProgress) {

}success:^(NSURLSessionDataTask*_Nonnulltask,id_NullableresponseObject) {

NSLog(@"sucess = %@",responseObject);

}failure:^(NSURLSessionDataTask*_Nullabletask,NSError*_Nonnullerror) {

NSLog(@"error = %@",error);

}];

上一篇 下一篇

猜你喜欢

热点阅读