- (AFSecurityPolicy*)customSecurityPolicy { /**** SSL Pinning ****/ NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"你的证书" ofType:@"cer"]; NSData *certData = [NSData dataWithContentsOfFile:cerPath]; AFSecurityPolicy *securityPolicy = [[AFSecurityPolicy alloc] init]; [securityPolicy setAllowInvalidCertificates:NO]; [securityPolicy setPinnedCertificates:@[certData]]; [securityPolicy setSSLPinningMode:AFSSLPinningModeCertificate]; /**** SSL Pinning ****/ return securityPolicy; }
然后在管理器里这么设置
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; /**** SSL Pinning ****/ [manager setSecurityPolicy:[self customSecurityPolicy]]; /**** SSL Pinning ****/ [manager GET:@"网站的url" parameters:params success:^(AFHTTPRequestOperation *operation, NSDictionary* responseObject) { //这里是你自己的代码了 } failure:^(AFHTTPRequestOperation *operation, NSError *error) { //注释同上 }];
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
时间: 2024-10-17 02:29:26