0

当我向 RKObjectManager 提出请求时,如何禁用证书验证?

因为我收到此错误:此服务器的证书无效。您可能正在连接到伪装成“网络服务地址”的服务器,这可能会使您的机密信息面临风险。”

谢谢 !

重复的问题: 我想通过 AFNetworking 允许无效的 SSL 证书

4

2 回答 2

1

If you are simply doing some tests against some server with the certificate misconfigured you can compile with the preprocessor macro _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ defined, and the request will bypass the certificate check.

I do not recommend that approach for a production server. If a production server has a misconfigured SSL certificate, you should try to fix it (if you can) or inform the owners of the server to fix it.

于 2013-07-24T20:23:31.107 回答
0

如果您使用 RestKit 使用

client.allowsInvalidSSLCertificate = YES;

不会工作,而是这样做:

如果你手动添加了rest kit到你的项目中,点击 RestKit.xcodeproj 去 project > Build Settings > Preprocessor Macros

并添加_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_=1

就这样结束了。

于 2014-01-27T15:10:27.763 回答