我想允许无效的 SSL 证书。我的主要代码如下:
myClient = [[MyClient alloc] init];
[myClient getHtml:@"/path/to/the/distination.html"];
MyClient 类代码如下:
#import <Foundation/Foundation.h>
#import "AFNetworking.h"
@interface MyClient : NSObject
- (void)getHtml:(NSString *)path;
@end
#define _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_
@implementation MyClient
- (void)getHtml:(NSString *)path
{
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://trusted.server.net"]];
[httpClient getPath:path parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error = %@", error);
}];
}
@end
我阅读了下面的页面并尝试了宏,但这不起作用。
自签名证书 SSL · 问题 #189 · AFNetworking/AFNetworking https://github.com/AFNetworking/AFNetworking/issues/189
请帮我...