我想通过AFNetworking允许无效的SSL证书 [英] I want to allow invalid SSL certificates with AFNetworking
本文介绍了我想通过AFNetworking允许无效的SSL证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想允许使用无效的SSL证书. 我的主要代码如下:
I want to allow invalid SSL certificates. My main code is below:
myClient = [[MyClient alloc] init];
[myClient getHtml:@"/path/to/the/distination.html"];
MyClient类代码如下:
The MyClient class code is below:
#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
我阅读了以下页面,并尝试了宏,但这是行不通的.
I read below page and tried the macro but this doesn't work.
自签名证书SSL·发行#189·AFNetworking/AFNetworking https ://github.com/AFNetworking/AFNetworking/issues/189
请帮助我...
推荐答案
使用AFNetworking允许无效的SSL证书.在#import Availability.h
To allow Invalid SSL Certificate with AFNetworking. Add the following line in AFURLConnectionOperation.h below #import Availability.h
#define _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ 1
这篇关于我想通过AFNetworking允许无效的SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文