【发布时间】:2013-12-28 12:53:48
【问题描述】:
我一直在使用以下代码
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
operation.allowsInvalidSSLCertificate=YES;
现在我已将 AFNetworking 更改为 2.0 的最新版本。 operation.allowsInvalidSSLCertificate 不再适用于 AFHTTPRequestOperation。根据我使用的文件
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.securityPolicy.allowInvalidCertificates = YES;
我的请求代码是
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog (@"success: %@", operation.responseString);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", error.description);
}
];
[operation start];
[operation waitUntilFinished];
但这不适用于需要证书的 HTTPS。我应该怎么做才能完成这项工作?
【问题讨论】:
标签: ios objective-c afnetworking-2