У меня есть интегрированная AFNetworking для защищенных запросов. Я хочу использовать SSL-пиннинг, но когда я добавляю ниже двух строк, выдаю NSException
AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey];
manager.securityPolicy = policy;
- (void)startConnectionForRequest:(ServiceRequest *)request completionBlock:(ServerConnectionCompletionBlock)block
{
urlString = [NSString stringWithFormat:@"%@%@",BASE_URL,request.apiName];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"application/json"];
AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey];
manager.securityPolicy = policy;
[manager.requestSerializer setTimeoutInterval:15.0];
NSDictionary * reqParams = @{
@"params":request.apiParams?request.apiParams:@"",
};
NSLog(@"%@[%@] ",reqParams,request.apiName);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
self->currentOperation = [manager POST:urlString
parameters:reqParams
progress:nil
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[self handleSuccessWithResponse:responseObject forRequest:request completionBlock:block];
}
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[self handleFailureWithError:error forRequest:request completionBlock:block];
}];
});
}
Исключение при получении в журнале составляет
*** Terminating app due to uncaught exception 'Invalid Security Policy', reason: 'A security policy configured with `AFSSLPinningModeCertificate` can only be applied on a manager with a secure base URL (i.e. https)'
Буду признателен за любую помощь.