Im new to the AFNetworking framework and the SSL Pinning. I already did the :
#define _AFNETWORKING_PIN_SSL_CERTIFICATES_ = 1
but dont think its enough, its correct? How can i do this? Heres my current request :
NSArray *info = @{@"action" : @"test"};
NSError * error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:info options:NSJSONWritingPrettyPrinted error:&error];
NSMutableURLRequest*request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:url]];
NSMutableData *body = [NSMutableData data];
[body appendData:jsonData];
[request setHTTPBody:body];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"content-type"];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:request.URL];
[httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation
*operation, id responseObject) {
NSError *error;
NSString *responseString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"response String %@",responseString);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@",error.localizedDescription); }];
[operation start];
The request works just fine, but i dont know if its really pinning the ssl.
在AFSSLPinningModeCertificate
调用start之前,必须将SSLPinningMode
属性设置为AFJSONRequestOperation
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.