iOS配置HTTPS
NSString *httpURL = @"https://xxxxx";
AFHTTPSessionManager * manager = [[AFHTTPSessionManager manager]initWithBaseURL:[NSURL URLWithString:httpURL]];
//设置请求格式
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
//设置请求超时
manager.requestSerializer.timeoutInterval = 15.0f;
//设置返回格式
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"xxx" ofType:@"cer"];//证书的路径
NSData *cerData = [NSData dataWithContentsOfFile:cerPath];
NSSet *cerset = [NSSet setWithObjects:cerData, nil];
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
//是否需要验证自建证书
securityPolicy.allowInvalidCertificates = YES;
//证书的域名与请求的域名是否设置一致
securityPolicy.validatesDomainName = NO;
securityPolicy.pinnedCertificates = cerset;
manager.securityPolicy = securityPolicy;
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setObject:@"186xxxxxxx" forKey:@"phone"];
[manager GET:httpURL parameters:dict headers:nil progress:^(NSProgress * _Nonnull downloadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSString *result =[[ NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"返回--%@",result);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];