zoukankan      html  css  js  c++  java
  • AFNetworking2.x https 常用代码

    - (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) {
    //注释同上
    }];
  • 相关阅读:
    leetcode122
    leetcode121
    leetcode773
    leetcode803
    leetcode658
    leetcode723
    leetcode134
    leetcode340
    leetcode721
    leetcode362
  • 原文地址:https://www.cnblogs.com/li-baibo/p/5141312.html
Copyright © 2011-2022 走看看