Sunday, 15 February 2015

ios - How can I allow https connection using AFNetworking? -



ios - How can I allow https connection using AFNetworking? -

i have afnetworking set not take https urls. how can afnetworking connect via ssl.

i have next code:

nsmutableurlrequest *apirequest = [self multipartformrequestwithmethod:@"post" path: pathstr parameters: params constructingbodywithblock: ^(id <afmultipartformdata>formdata) { //todo: attach file if needed }]; afjsonrequestoperation* operation = [[afjsonrequestoperation alloc] initwithrequest: apirequest]; [operation setcompletionblockwithsuccess:^(afhttprequestoperation *operation, id responseobject) { //success! completionblock(responseobject); } failure:^(afhttprequestoperation *operation, nserror *error) { //failure :( nslog(@"%@", error); completionblock([nsdictionary dictionarywithobject:[error localizeddescription] forkey:@"error"]); }]; [operation start];

operation.securitypolicy.allowinvalidcertificates = yes;

this code important. if dont add together error.

ios objective-c ios4 afnetworking

No comments:

Post a Comment