首页 > 代码库 > YTKNetworkConfig配置HTTPS请求
YTKNetworkConfig配置HTTPS请求
YTKNetworkConfig配置HTTPS请求
<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #ad91cc } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #e44347 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #526eda } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #93c96a } p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #4dbf56 } p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #ffffff; min-height: 16.0px } span.s1 { } span.s2 { color: #ffffff } span.s3 { color: #93c96a } span.s4 { color: #4dbf56 } span.s5 { color: #526eda } span.s6 { color: #c2349b } span.s7 { font: 14.0px "PingFang SC" }</style>YTKNetworkConfig *config = [YTKNetworkConfig sharedConfig];
config.baseUrl = @"https://139.224.186.241:8443/ma/";
// config.baseUrl = @"http://192.168.10.20:8095/CNParkAppService";
config.cdnUrl = @"http://218.17.152.138:8095/CNParkAppService-2.0/";
config.securityPolicy.allowInvalidCertificates = YES;
config.securityPolicy.validatesDomainName = NO;
// AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:request.pinningMode];
// [securityPolicy setAllowInvalidCertificates:YES];
// [securityPolicy setValidatesCertificateChain:request.validatesCertificateChain];
// [securityPolicy setValidatesDomainName:request.validatesDomainName];
// [securityPolicy setPinnedCertificates:customSecurityCertificates];
// 方式一 两句就可以-----ca证书
// AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
// manager.responseSerializer = [AFHTTPResponseSerializer serializer];
// manager.securityPolicy.validatesDomainName = NO; // 关键语句1
// manager.securityPolicy.allowInvalidCertificates = YES; // 关键语句2
//// [manager GET:@"https://kyfw.12306.cn/otn/leftTicket/init" parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
//// NSLog(@"=================%@", responseObject);
//// } failure:^(NSURLSessionDataTask *task, NSError *error) {
////
//// }];
// [manager POST:@"https://139.224.186.241:8443/ma/userBase/register" parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
//
// } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// NSLog(@"=================%@", responseObject);
// } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//
// }];
YTKNetworkConfig配置HTTPS请求