美文网首页
AFNetWorking 3.0 https 忽略证书

AFNetWorking 3.0 https 忽略证书

作者: James_Geng | 来源:发表于2016-05-10 17:31 被阅读1504次

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);

}];

相关文章

网友评论

      本文标题:AFNetWorking 3.0 https 忽略证书

      本文链接:https://www.haomeiwen.com/subject/iyyyrttx.html