相关疑难解决方法(0)

允许使用AFNetworking的无效证书

我一直在使用以下代码

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
operation.allowsInvalidSSLCertificate=YES;
Run Code Online (Sandbox Code Playgroud)

现在我已将AFNetworking更改为2.0的最新版本.operation.allowsInvalidSSLCertificate不与工作了AFHTTPRequestOperation.根据我使用的文件

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.securityPolicy.allowInvalidCertificates = YES;
Run Code Online (Sandbox Code Playgroud)

我的请求代码是

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];

[operation  setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

    NSLog (@"success: %@", operation.responseString);

}
                                  failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                                      NSLog(@"error: %@",  error.description);
                                  }
 ];

[operation start];
[operation waitUntilFinished];
Run Code Online (Sandbox Code Playgroud)

但这不适用于需要证书的HTTPS.我应该怎么做才能使这项工作?

objective-c ios afnetworking-2

9
推荐指数
1
解决办法
8989
查看次数

如何在不编辑iOS中的/ etc/hosts的情况下使用直接ip访问HTTPS?

默认情况下,example.com解析为123.123.123.123,

但如果我希望它得到解决100.100.100.100.

对于http,我只需将URL更改http://100.100.100.100为标题为"Host:example.com".

但它不适用于HTTPS.(错误:SSL证书问题:证书链无效).

我的问题不是原因,我不想跳过证书验证.

如何在Objective-C中获得与curl相同的效果

--resolve 选项:

--resolve <host:port:address>
          Provide a custom address for a specific host and port pair. Using this, you can make the  curl  requests(s)
          use  a specified address and prevent the otherwise normally resolved address to be used. Consider it a sort
          of /etc/hosts alternative provided on the command line. The port number should be the number used  for  the
          specific  protocol  the  host  will …
Run Code Online (Sandbox Code Playgroud)

dns objective-c ios afnetworking

6
推荐指数
1
解决办法
1271
查看次数

标签 统计

ios ×2

objective-c ×2

afnetworking ×1

afnetworking-2 ×1

dns ×1