码迷,mamicode.com
首页 > Web开发 > 详细

AFNetworking2.0 访问HTTPS服务器

时间:2014-09-04 18:50:09      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   div   sp   log   on   

在AFNetworking2.0下想要访问HTTPS服务器,需要做如下设置:

 

    AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
    [securityPolicy setAllowInvalidCertificates:YES];
    
    NSURL *URL = [NSURL URLWithString:url];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
    AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    [op setSecurityPolicy:securityPolicy];
    op.responseSerializer = [AFJSONResponseSerializer serializer];
    [op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        //Success
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        //Failed
    }];

 

AFNetworking2.0 访问HTTPS服务器

标签:style   blog   http   color   io   div   sp   log   on   

原文地址:http://www.cnblogs.com/kilinli/p/3956616.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!